原理->树叶飘落动作分析:
树叶下落过程分解为:下落+摆动+叶片自传。
也就是只要将这三个动作实现,并同时执行就可以实现树叶飘落的效果。
- void resetLeafPos(CCNode* sender);
- void playLeafAnim(CCSprite *spriteLeaf);
- 1:第一次初始化;2:落叶动作的实现;3:下落动作完成重新设定落叶开始。
-
- <span style="font-size:12px;">bool Leaf::init()
- {
- CCSprite *spriteLeaf1 = CCSprite::spriteWithFile("img_yezi_1.png");
- spriteLeaf1->setRotation(30);
- spriteLeaf1->setAnchorPoint(ccp(0.5, 3));
- spriteLeaf1->setPosition(ccp(450, 500));
- spriteLeaf1->setScale(0.5);
-
- this->addChild(spriteLeaf1,100,TAG_LEAF1);
- this->playLeafAnim(spriteLeaf1);
-
- CCSprite *spriteLeaf2 = CCSprite::spriteWithFile("img_yezi_2.png");
- spriteLeaf2->setRotation(50);
- spriteLeaf2->setAnchorPoint(ccp(0.5, 3));
- spriteLeaf2->setPosition(ccp(200, 540));
- spriteLeaf2->setScale(0.5);
-