Esempio n. 1
0
void TestParticleDisplay::onEnter()
{
    ArmatureTestLayer::onEnter();
    setTouchEnabled(true);

    animationID = 0;

    armature = Armature::create("robot");
    armature->getAnimation()->playByIndex(0);
    armature->setPosition(VisibleRect::center());
    armature->setScale(0.48f);
    armature->getAnimation()->setSpeedScale(0.5f);
    addChild(armature);


    ParticleSystem *p1 = CCParticleSystemQuad::create("Particles/SmallSun.plist");
    ParticleSystem *p2 = CCParticleSystemQuad::create("Particles/SmallSun.plist");

    Bone *bone  = Bone::create("p1");
    bone->addDisplay(p1, 0);
    bone->changeDisplayByIndex(0, true);
    bone->setIgnoreMovementBoneData(true);
    bone->setZOrder(100);
    bone->setScale(1.2f);
    armature->addBone(bone, "bady-a3");

    bone  = Bone::create("p2");
    bone->addDisplay(p2, 0);
    bone->changeDisplayByIndex(0, true);
    bone->setIgnoreMovementBoneData(true);
    bone->setZOrder(100);
    bone->setScale(1.2f);
    armature->addBone(bone, "bady-a30");
}
Esempio n. 2
0
void TestParticleDisplay::onEnter()
{
    ArmatureTestLayer::onEnter();

    auto listener = EventListenerTouchAllAtOnce::create();
    listener->onTouchesEnded = CC_CALLBACK_2(TestParticleDisplay::onTouchesEnded, this);
    _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);

    animationID = 0;

    armature = Armature::create("robot");
    armature->getAnimation()->playWithIndex(0);
    armature->setPosition(VisibleRect::center());
    armature->setScale(0.48f);
    armature->getAnimation()->setSpeedScale(0.5f);
    addChild(armature);


    ParticleSystem *p1 = CCParticleSystemQuad::create("Particles/SmallSun.plist");
    ParticleSystem *p2 = CCParticleSystemQuad::create("Particles/SmallSun.plist");

    Bone *bone  = Bone::create("p1");
    bone->addDisplay(p1, 0);
    bone->changeDisplayWithIndex(0, true);
    bone->setIgnoreMovementBoneData(true);
    bone->setLocalZOrder(100);
    bone->setScale(1.2f);
    armature->addBone(bone, "bady-a3");

    bone  = Bone::create("p2");
    bone->addDisplay(p2, 0);
    bone->changeDisplayWithIndex(0, true);
    bone->setIgnoreMovementBoneData(true);
    bone->setLocalZOrder(100);
    bone->setScale(1.2f);
    armature->addBone(bone, "bady-a30");
}
Esempio n. 3
0
void Hero::changeMount(Armature *armature)
{
    if (armature == nullptr)
    {
        retain();

        playWithIndex(0);
        //Remove hero from display list
        m_pMount->getBone("hero")->removeDisplay(0);
        m_pMount->stopAllActions();

        //Set position to current position
        setPosition(m_pMount->getPosition());
        //Add to layer
        m_pLayer->addChild(this);

        release();

        setMount(armature);
    }
    else
    {
        setMount(armature);

        retain();
        //Remove from layer
        removeFromParentAndCleanup(false);

        //Get the hero bone
        Bone *bone = armature->getBone("hero");
        //Add hero as a display to this bone
        bone->addDisplay(this, 0);
        //Change this bone's display
        bone->changeDisplayWithIndex(0, true);
        bone->setIgnoreMovementBoneData(true);

        setPosition(Vec2(0,0));
        //Change animation
        playWithIndex(1);

        setScale(1);

        release();
    }

}