pixi-actionPixi.js 动画插件
pixi-action,一个类似 cocos2d-x 使用方法的 Pixi.js 动画插件。
var renderer = new PIXI.autoDetectRenderer(800,600); document.body.appendChild(renderer.view); var stage = new PIXI.Container(); var sprite1 = new Sprite(resources['res/img/animal.png'].texture); var action_move = PIXI.action.MoveTo(500, 400, 2); // 移动动画 var animation = PIXI.actionManager.runAction(cat, action_moveto); // 执行动画 animation.on('end', function(elapsed) { console.log('action end.'); }); function animate() { window.requestAnimationFrame(animate); renderer.render(stage); PIXI.actionManager.update(); // update actions,这句必须加上 } animate();
使用非常简单,目前支持以下动画:
1. Action Move:Include: MoveTo , MoveBy
2. Action Scale:Include: ScaleTo , ScaleBy
3. Action Rotate:Include: RotateTo , RotateBy
4. Action Fade:Include: FadeIn , FadeOut
5. Action Blink:Include: Blink
6. Action Tint:Include: TintTo , TintBy
7. Action Skew:Include: SkewTo , SkewBy
8. Action Pivot:Include: PivotTo , PivotBy
9. Action Repeat:Include: Repeat and cancelAction
10. Action Sequence: Include: Sequence
11. Action Delay:Include: DelayTime
12. Action CallFunc:Include: CallFunc
DEMO 地址:http://git.hust.cc/pixi-action/
评论