Getting started with the j2_2d game (5) to achieve explosive effects and add a prop Missile

Source: Internet
Author: User

5. Implement the explosive effect and add a prop Missile
Most games have a variety of effects, which were once an important selling point in genie mobile games ,. Light is a variety of special effects that cannot produce a good game, but a good game cannot have a good effect.
Many people think that the performance layer of a game sometimes has little to do with the game logic itself. It is often to draw another layer of performance Layer on the final screen. However, communication between the game logic and the performance layer is very important. This communication is often reflected in latency and waiting. For example, when an airplane explodes, it does not accept any user input, and the explosion effect will continue to follow the plane's fall, or even the explosion scope will affect the surrounding objects. The game will continue until the explosion ends. Communication between the game logic and the performance layer is very complicated. Here I suddenly felt guilty, and we started out without analyzing the game. The game was completely based on hard coding. I thought of it, and everyone would see it. Aircraft is just a sprite and is not designed as a state machine, which makes communication between the effect layer and the logic layer somewhat cartoon. Maybe this article gives you the joy of writing your first game, and brings you a little worry about the scalability and complexity of the game. Maybe this is more meaningful than a hard-coded game? Who can say it well? I still think that games with good scalability are the masterpiece of great game architects. I believe you will redesign the game after having one or two good ideas, make it a little like a "system ". However, good technologies do not necessarily produce good games ...... Haha
It's a long journey. Come to reality, boys and girls! Goon.
Describe our explosion effect. After a bullet hits the plane, the bullet will quickly disappear, and the plane image will remain unchanged. At this time, the explosion effect will be placed above the plane image, and then the boom animation will be displayed, during this period, the plane does not accept any movement instructions because of its lose control. The plane disappears after the explosion.
Our explosion effects:
GameObject explosion ;//
Initialize once:
Img = ImageTools. getImage ("/pic/explosion.png ");//
Explosion = new GameObject (img, 32, 32 );
Initialization:
Explosion. reset ();
Explosion. lifetime = 3; // lifecycle positioning trigger
Logic processing:
If (gameover) {// if the game ends, display the effect class
Explosion. paint (g );
Explosion. update ();
If (! Explosion. alive) {// when the lifecycle ends
Plane. alive = false; // disable plane
G. setColor (255,255,255); // output comments, next Decomposition
G. drawString (StringTools. timeOpinion (gametime), 5, 22, g. LEFT | g. TOP );
G. drawString ("fly 0.1 ver by favo yang", 2,100, g. LEFT | g. TOP );

Related Article

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.