pixi-actionPixi.js 动画插件

联合创作 · 2023-09-22 04:20

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/ 

浏览 6
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报