lightningJS之动画

1、元素位置

支持的属性

名称类型默认值描述
xFloat0相对父对象的x坐标
yFloat0相对父对象的y坐标
wFloat0宽度,如果没有设置,从激活的纹理继承
hFloat0高度,如果没有设置,从激活的纹理继承
mountFloat0相对坐标(与x,y相等)的纹理对齐
mountXFloat0水平轴的纹理挂载点
mountYFloat0竖直轴的纹理挂载点

 2、动画

 3、过度

 4、纹理图片

5、实现功能

 pixJS实现的功能,跟踪目标点,如果与目标点距离小于1,重新设置目标点。要求使用lightningJS实现相似功能

const app = new PIXI.Application();
document.body.appendChild(app.view);

app.stage.interactive = true;

const bg = PIXI.Sprite.from('examples/assets/bg_plane.jpg');

app.stage.addChild(bg);

const cells = PIXI.Sprite.from('examples/assets/cells.png');

cells.scale.set(1.5);

const mask = PIXI.Sprite.from('examples/assets/flowerTop.png');
mask.anchor.set(0.5);
mask.x = 310;
mask.y = 190;

cells.mask = mask;

app.stage.addChild(mask, cells);

const target = new PIXI.Point();

reset();

function reset() {
    target.x = Math.floor(Math.random() * 550);
    target.y = Math.floor(Math.random() * 300);
}

app.ticker.add(() => {
    mask.x += (target.x - mask.x) * 0.1;
    mask.y += (target.y - mask.y) * 0.1;

    if (Math.abs(mask.x - target.x) < 1) {
        reset();
    }
});

使用lightningJS中的Transition的x,y属性以及事件finish,代码参考:

https://github.com/wuli2496/OJ/tree/master/topcoder/lightningjs/com.medium

参考资料:

https://rdkcentral.github.io/Lightning/docs/player/player

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kgduu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值