当前位置: 首页>>代码示例>>C++>>正文


C++ ParticleBatchNode::setAnchorPoint方法代码示例

本文整理汇总了C++中ParticleBatchNode::setAnchorPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleBatchNode::setAnchorPoint方法的具体用法?C++ ParticleBatchNode::setAnchorPoint怎么用?C++ ParticleBatchNode::setAnchorPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParticleBatchNode的用法示例。


在下文中一共展示了ParticleBatchNode::setAnchorPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onTouchEnded

void GameScene::onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *unused_event)
{
    Vec2 size = Director::getInstance()->getVisibleSize();
    
    auto HandAnimation = Animation::createWithSpriteFrames(mHandAnimations, 0.05);
    auto HandAnimate = Animate::create(HandAnimation);
    mHandSprite->runAction(HandAnimate);

    if (mKnife == nullptr) return;
    
    CCLOG ("%f\n", mKnife->getKnife()->getPositionY());
    if (mKnife->isInCutterEdge())
    {
        
        // 失败脸部表情
        auto FaceAnimation = Animation::createWithSpriteFrames(mFaceAnimationFail, 1);
        auto FaceAnimate = Animate::create(FaceAnimation);
        mFaceSprite->runAction(FaceAnimate);
        
        MusicButton::getInstance()->playCatchCutterEdge();
        
        // 停止刀子
        mKnife->getKnife()->getPhysicsBody()->setVelocity(Vec2(0, 0));
        mKnife->getKnife()->getPhysicsBody()->setGravityEnable(false);
        
        // 流血效果
        ParticleSystem* BloodPar = ParticleSystemQuad::create("blood.plist");
        BloodPar->retain();
        ParticleBatchNode* BloodNode = ParticleBatchNode::createWithTexture(BloodPar->getTexture());
        BloodNode->addChild(BloodPar);
        BloodNode->setAnchorPoint(Vec2::ZERO);
        BloodNode->setPosition(Vec2(250, 300));
        addChild(BloodNode, 10);
        BloodPar->release();
        
        // NG
        scheduleOnce(schedule_selector(GameScene::gameOver), 1);
    }
    else if (mKnife->isInHilt())
    {
        // 成功脸部表情
        auto FaceAnimation = Animation::createWithSpriteFrames(mFaceAnimationSucc, 0.5);
        auto FaceAnimate = Animate::create(FaceAnimation);
        mFaceSprite->runAction(FaceAnimate);
        
        MusicButton::getInstance()->playCatchHilt();
        
        // 刀子动作
        mKnife->getKnife()->getPhysicsBody()->setVelocity(Vec2(0, 0));
        mKnife->getKnife()->getPhysicsBody()->setGravityEnable(false);
        auto KnifeMove = MoveTo::create(0.3, Vec2(Vec2(size.x-140, size.y-82)));
        auto KnifeScale = ScaleTo::create(0.4, 0.1);
        auto KnifeSpa = Spawn::create(KnifeMove, KnifeScale, NULL);
        mKnife->getKnife()->runAction(KnifeSpa);
        
        scheduleOnce(schedule_selector(GameScene::gotKnife), 0.5);
    }
    else
    {
        // Miss表情
        auto FaceAnimation = Animation::createWithSpriteFrames(mFaceAnimationMiss, 0.2);
        auto FaceAnimate = Animate::create(FaceAnimation);
        mFaceSprite->runAction(FaceAnimate);
    }
}
开发者ID:DPC11,项目名称:Knifes-game,代码行数:65,代码来源:GameScene.cpp


注:本文中的ParticleBatchNode::setAnchorPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。