Skip to content

Instantly share code, notes, and snippets.

@vkgtaro
Created February 26, 2015 06:43
Show Gist options
  • Save vkgtaro/952210d80130b50452d4 to your computer and use it in GitHub Desktop.
Save vkgtaro/952210d80130b50452d4 to your computer and use it in GitHub Desktop.
cocos2d-js のアニメーションを動かす / 反転させる ref: http://qiita.com/vkgtaro/items/f75b60b489803fb205d4
var animation = cc.AnimationCache.getInstance().getAnimation('animation_name');
animation.setRestoreOriginalFrame(true);
var animation_sprite = cc.Sprite.create( image_path, cc.rect(0, 0, width, height) );
animation_sprite.setPosition(220, 240);
layer.addChild(anime_sprite, 300);
animation_sprite.runAction( cc.RepeatForever.create( cc.Animate.create(animation)) );
animation_sprite.runAction( cc.MoveBy.create(10, cc.p(200,100) ) );
var animation_sprite2 = cc.Sprite.create( image_path, cc.rect(0, 0, width, height) );
animation_sprite2.setPosition(420, 240);
animation_sprite2.setScale(-1);
this.addChild(animation_sprite2, 300);
animation_sprite2.runAction( cc.RepeatForever.create( cc.Animate.create(animation)) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment