AlloyGameEngine2D 游戏引擎

联合创作 · 2023-09-27 18:15

AlloyGameEngine 让游戏制作变得超级容易,超快的 2d 渲染引擎,支持 webgl 和 canvas 渲染。

一分钟快速入门

要实现下面的效果:

可以使用下面的代码:

var bmp, stage = new Stage("#ourCanvas");
bmp = new Bitmap("img/atLogo.png");
//(0.5,0.5)==〉The center is the point of rotation
bmp.originX = 0.5;
bmp.originY = 0.5;
//bind click event, the event monitor can be accurate to pixel
bmp.onClick(function () {
    //apply a random filter to the bmp
    bmp.filter=[Math.random(), Math.random(), Math.random(), 1];
});
//add object to stage
stage.add(bmp);
var step = 0.01;
//loop
stage.onTick(function () {
    bmp.rotation += 0.5;
    if (bmp.scaleX > 1.5 || bmp.scaleX < 0.5) {
        step *= -1;
    }
    bmp.scaleX += step;
    bmp.scaleY += step;
});
浏览 5
点赞
评论
收藏
分享

手机扫一扫分享

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

手机扫一扫分享

编辑
举报