Elementary School of Cocos2d-x (10) -- & gt; particle Editor

Source: Internet
Author: User

File: save, save as (export plist File), new, Open

Samples: There are some examples in test. The texture addition function is not added to the current version... however, the particle system has a method to set images. if the requirements are not high, they can also be used... this function may be added to later versions.

The editor provides instructions to briefly introduce the functions on the right:

Radius mode: This mode only involves center movement. The following parameters must be valid.

Editor: whether the IsBackgroundMove background is dynamic and scaled.

Size: particle start size and end size

Angle: The moving direction of the particle... (-90) vertical downward

Life: particle life

Location: Set the PosVar value. SourcePosition is unnecessary.

Texture rendering: In general cases, you only need to remember: "The most common CC_BLEND_SRC and CC_BLEND_DST correspond to GL_ONE and GL_ONE_MINUS_SRC_ALPHA respectively ".

Color: StartColor, EndColor, StartColorVar, and EndColorVar indicate the initial color, ending color, and floating value of the particle.

Gravity mode: Setting of gravity and speed

Spin: particle Rotation

EmissionRate

The particle emission rate, that is, the number of particles emitted per second.

Here is a problem. I don't know if it is a bug. I 'd like to describe it to you:

CCParticleSystem does not read the value of EmissionRate when loading the. plist file. In fact, it is calculated by dividing the maximum number of particles by the particle life cycle.

1 // emission Rate
2 m_fEmissionRate = m_utotalparticipant/m_fLife;
A little hard to say, right. Why should I send all the particles out during the lifetime of the first particle?

This is a problem for CCParticleSystem to load the. plist file. The temporary solution is to manually call setEmissionRate to set the number of launches per second after the. plist file is loaded.

Export the. plist file and copy the corresponding image to the Resource folder of the new project...

(Note that the two files should be put together, or you cannot find them. Naturally, you can go to. plist to modify the path of the image resource, but there is no need to put them together)

To achieve the snow effect:

Normally, upload my demo code:

Particle testscene. h

[Cpp]
# Pragma once
# Include "cocos2d. h"
Using namespace cocos2d;
Class participant testscene: public CCScene
{
Public:
Participant testscene (void );
~ Participant testscene (void );
Static CCScene * scene ();
};
Particle testscene. cpp

[Cpp]
# Include "maid. h"
# Include "maid"
 
Particle testscene: FIG (void)
{
}
 
 
Particle testscene ::~ Participant testscene (void)
{
}
 
CCScene * MAID: scene ()
{
CCScene * scene = CCScene: create ();
CCLayer * layer = new participant testlayer ();
Scene-> addChild (layer );
Return scene;
}

Participant testlayer. h

[Cpp]
# Pragma once
# Include "cocos2d. h"
Using namespace cocos2d;
Class participant testlayer: public CCLayer
{
Public:
Virtual void onEnter ();
Protected:
CCParticleSystem * m_emitter;
CCSprite * m_background;
Unsigned int m_nOrder;
};
PartileTestLayer. cpp

[Cpp]
# Include "maid"
# Include "cocos2d. h"
Void MAID: onEnter ()
{
CCLayer: onEnter ();
// Note: If your layer inherits CCLayerColor, you must initialize the color value.
/* InitWithColor (ccc4 (127,127,127,255 ));*/
 
// Create a CCParticleSystem Particle System
CCNode * parent1 = CCNode: create (); // create a parent node
 
// Create a CCParticleSystemQuad system: each particle is represented by four vertices (Quad, rectangle ).
CCParticleSystemQuad * emitter1 = CCParticleSystemQuad: create ("pottersnow. plist ");
 
Emitter1-> setBlendAdditive (false); // whether to mix
 
CCSize s = CCDirector: sharedDirector ()-> getWinSize ();
 
Emitter1-> setPosition (ccp (s. width/2-30, s. height/2 + 60 ));
 
Parent1-> addChild (emitter1, 0, 1 );
 
AddChild (parent1, 10,100 0 );
}
Running effect:
 

 

 

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.