[Lgame entry school 005. Excellent spirit legends] Simple genie

Source: Internet
Author: User

[Lgame School]Simple genie

 

Keyword: lgame entry genie

What do you mean? Flowers? No, it's your heart ~

Reprinted please note, original address: http://blog.csdn.net/musicvs/article/details/7530117

 

 

 

:

 

ExcellentSpirit, in my personal understanding, is the creature and creature in the game. Of course, it must be understandable. The main character of the competition is the genie, and the monster that fights with the protagonist is also the genie ~ There are many other genie. Well, the genie is not mysterious. It is just an encapsulated animation.

 

Public class gamescreen extends screen {private final string tag = "gamescreen"; private limage bgimg = NULL;/* background image */private sprite girlsprite = NULL;/* genie: an archer girl */private sprites sprmgr = NULL;/* genie manager */Public gamescreen () {/* background image */bgimg = limage. createimage ("assets/bgimg.jpg");/* load the genie resource */girlsprite = new sprite ("assets/girl.png", 103,114);/* set the genie initial position */girlsprite. setlocation (50,250);/* Add the genie to the genie manager */sprmgr = new Sprites (); sprmgr. add (girlsprite) ;}@ override public void draw (lgraphics g) {/* draw an image. This is very simple. Just look at the function description, which is similar to the android API ~ */G. drawimage (bgimg, 0, 0);/* ------------- draw the genie ---------- * // * The createui method traverses all the genie in the genie manager, * and calls the createui method of the genie, it is equivalent to drawme. * It is the method used by the genie to draw itself */sprmgr. createui (g);/* The update method also traverses all the genie in the genie manager, * and calls the update method of the Genie. The update method updates the frames of the genie, * switch to the next frame of the sprite image. * Then, the elapsedtime parameter is the Refresh Interval (in milliseconds) */sprmgr. update (100) ;}@ override public void alter (ltimercontext timer) {}@ override public void ontouchdown (ltouch e) {}@ override public void ontouchup (ltouch E) {}@ override public void ontouchmove (ltouch e ){}}

 

SlaveThe Code shows that the genie is managed by a genie manager, and all the genie are drawn by the genie manager.

Alas, this example is a little too simple and I really don't know what to say ~

Okay, so I won't talk about it anymore ~

-

Long-winded:

GoodLet's talk about some things ~ Sprite is a default sprame class provided by lgame. If you don't like it, you can create one by yourself (well, you can do multiple )~ How to create? As long as your class implements the isprite interface, it is considered to be an genie class. Others can be used freely ~

-

Then, let's say:

ViewCheck sprite constructor:

 

ThisConstructors have three parameters:

1. filename resource path

2. truncate the width of the image resource at each frame of the row.

3. Col captures the image height at each frame.

-

The2. For a slight explanation of the 3rd parameters, this constructor requires such an image resource:

 

InstituteSome actions are in the same picture. I believe most of my friends know this. The row parameter is the image width divided by the width of each action, and the col parameter is the image height.

Okay, it's done ~

 

The last comment:

AlsoSome people have discovered that every time I use the gamescreen class, it inherits screen. In fact, lgame also has a canvasscreen class, but I still don't know when to use screen and when to use canvasscreen ~ I will share it with you later ~

 

Source code download: http://download.csdn.net/detail/musicvs/4289615

 

The original Article was first published on the Android-fans Forum:Http://www.android-fans.net/forum.php? MoD = viewthread & tid = 1493 & page = 1 & extra = # pid4389

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.