用CS2.1做了个帧动画, 0-90帧是 npc idle的动画, 100-170是npc移动动画
把sprite addChild加到Scene上时先gotoFrameAndPlay(0,90,true);
想实现点这个sprite,则动画变成100-180 帧的移动动画,移动到指定位置后又恢复 idle动画。
…
ActionTimeline *action = CSLoader::createTimeline(“npcNode.csb”);
npcSprite->runAction(action);
action->gotoFrameAndPlay(0,90,true);
//idle状态
listener->onTouchBegan = =](Touch* touch, Event* event) {
…
line a: action->gotoFrameAndPlay(100,170,true);
ActionInterval *moveaction = MoveTo::create(1.5f, targetPoiont);
npcSprite->runAction(moveaction);
line b: action->gotoFrameAndPlay(0,90,true);
…
getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, npcSprite);
类似这样的代码,无法实现移动时变成100-170,而是依然以idle状态移动。
如果把 line b:的恢复idle动画那段去掉,则移动和移动结束都是100-170帧的移动画面
正确的使用姿势应该是什么呢?
有专家么“?