首页 技术 正文
技术 2022年11月16日
0 收藏 376 点赞 4,732 浏览 1511 个字

1.关于

一个关于HTML5 2D渲染引擎,它的独特之处在于其拥有了canvas回调功能的WebGL,速度快,能够兼容所有设备,简单得说也就是跨平台了,我用的开发工具是WebStorm

2.参考API

https://github.com/kittykatattack/learningPixi

3.基本使用

创建一个PIXI的实例,并展示出来,通常需要以下几步:

  1.创建一个画布 (render)

    Pixi的渲染器对象将默认为WebGL,

   renderer = new PIXI.CanvasRenderer(256, 256);  OR  renderer = new PIXI.WebGLRenderer(256, 256);
   renderer.view为<canvas>对象
  // 通过自动选择的方式创建画布(800x500)
  // 并设置背景为黑色(16进制),第三个参数(options对象)是可选的
  // 然后将其添加到body中
  var renderer = PIXI.autoDetectRenderer(800, 500, {backgroundColor : 0x000000});
document.body.appendChild(renderer.view);

  2.创建一个舞台 (stage)  

// 之后的对象都存在于舞台之上
var stage = new PIXI.Container();  

   3.创建一个精灵 (sprite)      

    // 使用图片方式创建背景精灵
var background = new PIXI.Sprite.fromImage('assets/img/back.png');

  4.把精灵加入画布

    // 将背景精灵放置于舞台之上
stage.addChild(background);
5.渲染 Container
  renderer.render(stage);

4.支持的动作

ActionMove
PIXI.action.MoveTo(x, y, time);
PIXI.action.MoveBy(x, y, time);

ActionScale
PIXI.action.ScaleTo(scale_x, scale_y, time);
PIXI.action.ScaleBy(scale_x, scale_y, time);

ActionRotate
PIXI.action.RotateTo(rotation, time);
PIXI.action.RotateBy(rotation, time);

ActionBlink
PIXI.action.Blink(count, time);

ActionFade
PIXI.action.FadeIn(time);
PIXI.action.FadeOut(time);

ActionSkew
PIXI.action.SkewTo(x, y, time);
PIXI.action.SkewBy(x, y, time);

ActionPivot
PIXI.action.PivotTo(x, y, time);
PIXI.action.PivotBy(x, y, time);

ActionTint
PIXI.action.TintTo(tint, time);
PIXI.action.TintBy(tint, time);

ActionSequence
PIXI.action.Sequence(actions);

ActionRepeat
PIXI.action.Repeat(action, count);

RepeatForever
PIXI.action.Repeat(action);

ActionDelay
PIXI.action.Delay(time);

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,991
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,505
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,349
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,134
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,766
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,844