Cocos2dx meteor effect implementation

Source: Internet
Author: User

Dionysoslai ([email protected]) 2014/8/28

It is not the best choice for a meteor that is used to set off a beautiful artistic conception and that is a few moments in the sky. For those who are infatuated with love, they will be in the beautiful scenery of this moment. Today, I am waiting for rough people to "spoil" this beautiful thing.

Functional requirements:

1. Achieve the meteor effect. The effect is the same as that achieved:


Function Analysis:

1. image analysis can be simplified as follows:

Unchanged part: meteor head;

Tail part: the tail of a meteor. Note that the tail of a meteor is rough and sharp. At the same time, the color changes from start to end. The variation varies depending on the position.

Particle part: in the meteor tail area, you can use a few small stars.


Therefore, the production of a meteor is:Genie movement + tail effect + fine-grained Little Star particle effect.


Function implementation:

The key part is the preparation of the meteor tail part, which is placed on the Particle effect of the small star, that is, it is slowly adjusted by yourself.

Achieve meteor tail:

The ccmotionstreak class that comes with cocos2dx is used here. For ccmotionstreak applications, you can refer to the built-in test example of the engine.

The core code is as follows:

m_pMoStar = CCMotionStreak::create(0.5f, 1, 7, ccWHITE,"page9/steak.png" );m_pMoStar->setPosition(CCPointZero);m_pMoStar->setVisible(false);addChild(m_pMoStar);

Then, update the location of the Instance continuously.

Some of the preceding values are based on the image. The image is dragged to the end as follows:

There is a way out of the picture here, which was originally used to cut the light effect in the fruit game. In actual use, the image should be thick and thin, and its tail has other colors.

For detailed code and resource path, visit here:

Tomorrow's Mid-Autumn Festival, I wish you a happy holiday!

Cocos2dx meteor effect implementation

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: 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.