A technique of using lanimationtimeline in lufylegen engine

Time:2021-3-3

Introduction to lufylegen engine

Lufylegen is an HTML5 open source engine, which implements the development of HTML5 using the syntax of ActionScript 3.0. It includes lsprite, lbitmapdata, lbitmap, lloader, lurlloader, ltextfield, Levent and other classes familiar to as developers, and supports Google Chrome, Firefox, opera, IE9, IOS, Android and other popular environments. Using lufylegen can easily use object-oriented programming, and can cooperate with box2dweb to make physics games. In addition, it also has built-in ltweenlite slow class and other very practical functions. Now start using it, it can let you enter the world of HTML5 faster!


The above is an introduction to the API
API address:lufylegend.js Chinese document

LAnimationTimeline
Lanimationtimeline is a set of encapsulated sprite animation methods, which can make a sprite animation according to the specified number of frames.
Accept two parametersintroduce
The following is the official sample code

LInit(50, "legend", 800, 480, main);
var imgData = [
    {name : "player-0", path : "./player-0.png"}, 
    {name : "player-1", path : "./player-1.png"}, 
    {name : "player-2", path : "./player-2.png"}, 
    {name : "player-3", path : "./player-3.png"}, 
    {name : "player-4", path : "./player-4.png"}
];
function main () {
    LLoadManage.load(imgData, null, gameInit);
}
function gameInit(result) {
    var list = LGlobal.divideCoordinate(480, 210, 1, 4);
    var data = new LBitmapData(result["player-0"], 0, 0, 120, 210);
    var playerLeft = new LAnimationTimeline(data, list);
    addChild(playerLeft);

    var datas = [];
    var listChild = [];
    for (var i = 0; i < 4; i++) {
        datas.push(new LBitmapData(result["player-" + (i + 1)]));
        listChild.push({dataIndex : i, x : 0, y : 0, width : 120, height : 210, sx : 0, sy : 0});
    }
    var playerRight = new LAnimationTimeline(datas, [listChild]);
    playerRight.x = 200;
    addChild(playerRight);
}

actually

var data = new LBitmapData(result["player-0"], 0, 0, 120, 210);

Can be changed to

var data = new LBitmapData(result["player-0"]);

Because when I read the source code,LAnimationTimelineThat’s rightLAnimationThe packaging of theLAnimationWill be inonframeZhongduidataconductsetPropertiesSelect again.
The basis of selection isvar list = LGlobal.divideCoordinate(480, 210, 1, 4);InlistTwo dimensional array of.