【问题标题】:Stop Animation of Sprites when touched in centre Cocos2d在中心 Cocos2d 中触摸时停止 Sprite 的动画
【发布时间】:2011-10-15 02:17:38
【问题描述】:

当用户触摸精灵中心的精灵时,我想停止在我的CCSprite 上运行的所有动画。

谁能帮我想出代码来执行此操作或提供可能有帮助的教程链接。

【问题讨论】:

    标签: ios cocos2d-iphone


    【解决方案1】:

    你并没有真正在那里问过问题,我已经编辑了你的问题。我认为这应该给你一个好的开始。

    实现 CCTargetedTouchDelegateProtocol 并关注此方法。

    -(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
    {
        if (CGRectContainsPoint(GCRectMake(/*Define a rect to represent the center of your sprite*/), [touch locationInView:/*View where you want the touch to be located, usually linked to the CCDirectors OpenGL view*/])
        {
            [sprite stopAllActions];
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多