Andengine Particle System

Source: Internet
Author: User

It can only be a simple research. After using the images in the example, the particle effect disappears when you click the screen.

Public class mainactivity extends simplebasegameactivity {Private Static final int camera_width = 480; Private Static final int camera_height = 720; private bitmaptextureatlas mbitmaptextureatlas; private itextureregion seconds; Public engineoptions oncreateengineoptions () {final camera = new camera (0, 0, camera_width, camera_height); return New engineoptions (true, screenorientation. portrait_fixed, new ratioresolutionpolicy (camera_width, camera_height), camera) ;}@ overrideprotected void oncreateresources () {bitmaptextureatlastextureregionfactory. setassetbasepath ("GFX/"); mbitmaptextureatlas = new bitmaptextureatlas (gettexturemanager (), 32, 32, textureoptions. bilinear); mparticletextureregion = bitmaptextureatlastextureregionfactory. createfromasset (mbitmaptextureatlas, this, "maid", 0, 0); mbitmaptextureatlas. load () ;}@ overrideprotected scene oncreatescene () {final scene = new scene (); scene. setbackground (new background (0.09804f, 0.6274f, 0.8784f); circleparticipant emitter = new circleparticipant emitter (camera_width/2, camera_width/2, 30); // circular particle generator, the position is in the center of the screen, with a radius of 30 final spriteparticlesystem (emitter, 10, 60, 30, mparticletextureregion, getvertexbufferobjectmanager (). // use the image as the particle system. addparticipant leinitializer (New colorparticipant leinitializer <sprite> (1, 0, 0); // initialize it to the red participant system. addparticipant leinitializer (New alphaparticleinitializer <sprite> (0); // The Initialization is fully transparent. addparticipant leinitializer (New blendfunctionparticipant leinitializer <sprite> (gles1_gl _ src_alpha, gles1_gl _ One); participant system. addparticipant leinitializer (New velocityparticipant leinitializer <sprite> (-5, 5, 20, 10); // The first two values are values of horizontal acceleration, the following two values are the values of the vertical acceleration. addparticipant leinitializer (New rotationparticipant leinitializer <sprite> (0.0f, 360.0f); // The value range of the rotation angle is participant system. addparticipant leinitializer (New expireparticipant leinitializer <sprite> (6); // The duration of a single particle, I .e., the particle system. addparticipant lemodifier (New scaleparticlemodifier <sprite> (0, 5, 1.0f, 2.0f); // The particle generation process changes from the original size to the size of 2 times the size of the particle system. addparticipant lemodifier (New colorparticipant lemodifier <sprite> (0, 3, 1, 1, 0, 0.5f, 0, 0); // color change between 0 and 3 seconds. addparticipant lemodifier (New colorparticipant lemodifier <sprite> (4, 6, 1, 1, 0.5f, 1, 0, 1); // color change between 4 and 6 seconds. addparticipant lemodifier (New alphaparticlemodifier <sprite> (0, 1, 0, 1); // The transparency changes between 0 and 1 seconds. addparticipant lemodifier (New alphaparticlemodifier <sprite> (5, 6, 1, 0); // scene for transparency change between 5 and 6 seconds. attachchild (participant system); // screen touch event scene. setonscenetouchlistener (New ionscenetouchlistener () {public Boolean onscenetouchevent (scene pscene, touchevent pscenetouchevent) {If (pscenetouchevent. isactionup () {participant system. setparticipant lesspawnenabled (false);} return false ;}}); Return scene ;}}

If anything is wrong, you are welcome to make a picture.

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.