读书人

cocos2d_x+lua【二】 -sprite使用

发布时间: 2012-11-25 11:44:31 作者: rapoo

cocos2d_x+lua【2】 ------sprite使用
oDustGgg个人原创、欢迎转载、转载请注明出处、http://blog.csdn.net/odustggg/article/details/8164693
一、CCSprite的创建方法1、通过纹理来创建

--停止所有动画sprite:stopAllActions()--播放一次sprite:runAction(CCRepeat:actionWithAction(_animate_go, 1))--重复播放sprite:runAction(CCRepeatForever:actionWithAction(_animate_go))--停止动画aimate:stop()  --延时调用local action1 = CCMoveBy:actionWithDuration(1.0f, ccp(200, 200))local action2 = action1->reverse()sprite:runAction(CCSequence:actions(action1, CCDelayTime:actionWithDuration(1.0f), action2, NULL))--函数调用 CCCallFuncfunction Hello()CCLog("Hello, this your world!\n");endfunction Action()sprite:stopAllActions()sfcache = CCSpriteFrameCache:sharedSpriteFrameCache()sfcache:addSpriteFramesWithFile(".plist");local animFrames = CCMutableArray_CCSpriteFrame__:new(2)for i=1, 3 dolocal frame = sfcache:spriteFrameByName(i..".png");animFrames:addObject(frame)endlocal animation = CCAnimation:animationWithFrames(animFrames, 0.5)local animate = CCAnimate:actionWithAnimation(animation, false)animFrames:release()local action = CCCallFunc:actionWithTarget((CCObject*)this, callfunc_selector(Hello))sprite:runAction(CCSequence:actionsWithAction(animate))


读书人网 >操作系统

热点推荐