Home > other >  O solve shell animation method
O solve shell animation method

Time:09-21

Himself or small white, run into problems when doing the shells stuck, shells can realize continuous emission, is continuous frame images, animation, but not impossible to achieve know LAnimation, but it is always an error, please great god help me to solve the problem,


<meta charset="utf-8" & gt;
Document
<style>
Body {
margin:0;
padding:0;
border:0px;
}
</style>

<body>

<script>
Init (50, "legend", 800450, the main);
Var imgData=[https://bbs.csdn.net/topics/
{name: "back", path: "./images/back. JPG "},
{name: "item7", path: "./images/shells. PNG "}
];
Var imglist;
Var itemLayer;
Var anima;
Var step=20, stepindex=0;
The function main () {
LGlobal. SetDebug (true);
LLoadManage. Load (imgData, null, gameInit);
}
The function gameInit (result) {
Load//picture
Imglist=the result;
//the background layer
BackLayer=new LSprite ();
AddChild (backLayer);
AddBackGround ();
//shell layer
ItemLayer=new LSprite ();
BackLayer. AddChild (itemLayer);
AddEvent ();
}
The function addEvent () {
BackLayer. AddEventListener (LEvent. ENTER_FRAME onframe);
}

The function onframe () {
//traverse subset
For (var I=0; IItemLayer. ChildList that consists [I]. The run ();
If (itemLayer childList that consists [I] mode=="die") {
//remove the child in front of the
ItemLayer. RemoveChild (itemLayer. ChildList that consists [I]);
}

}
If (stepindex++ & gt; Step) {
Stepindex=0;
AddItem ();
}
}
The method of adding food//
The function addItem () {
Var item=new item ();
Item. X=20;
ItemLayer. AddChild (item);
}
//background
The function addBackGround () {
Var bitmap=new LBitmap (new LBitmapData (imglist [] "back"));
BackLayer. AddChild (bitmap);
}
//shells
The function Item () {
The base (this, LSprite, []);
var self=this;
The self. The mode="";
Var shall_list=LGlobal. DivideCoordinate 4-trichlorobenzene (256256);
Var shall_data=https://bbs.csdn.net/topics/new LBitmapData (imglist [" item7 "], 0,0,56,110);
Var bitmap=new LBitmap (shall_data);
Anima=new LAnimation (enclosing LSprite, shall_data, shall_list);
Anima=addEventListener (LEvent. ENTER_FRAME onframe);
The self. The addChild (anima);
}
//shells falling
Item. The prototype. The run=function () {
var self=this;
Self. + y=5;
}
</script>



  • Related