<p>Rather than using an image, I would suggest doing this kind of effect using a shader. I'm not familiar with Cocos2d-x, but some quick googling suggests that it can work with shaders. You'd use a pixel shader that calculates the distance of each pixel to the center of the pulse effect, then applies a function based on that distance to define the shape and appearance of the pulse.</p>

<p>I made a <a href="https://www.shadertoy.com/view/MdtXWX" rel="noreferrer">quick shadertoy</a> as a proof of concept and example.</p>

<p><img src="https://i.sstatic.net/49koo.png" alt="enter image description here"></p>

CC BY-SA 3.0
2016-05-04T10:24:59.313Z
Hey thanks a lot for sharing ur knowledge. I wrote a code but it seems to have some error ive edites the post with an image. I would appreciate if u cab give me help with that. Im constantly running into problems so i searched for ur contact number cuz i cant post image in a comment lol.
quinnavery
CC BY-SA 3.0
2016-05-04T16:17:46.320Z
@quinnavery ...did you just copy/paste the shadertoy into your code? :D You're going to need a bit more plumbing than that. It's written in GLSL, not C++, which is where most of the errors are coming from. If you're not familiar with using shaders in Cocos2d-x, you should look up some tutorials on the subject first, such as [this one](https://www.raywenderlich.com/10862/how-to-create-cool-effects-with-custom-shaders-in-opengl-es-2-0-and-cocos2d-2-x).
Nathan Reed
CC BY-SA 3.0
2016-05-08T17:03:50.183Z
hi, Im having some trouble with my developer.... he really doesnt know how to code (Just my opinion) I'm considering to hire somebody else to create the game for me. You really seem like you can code since u shared your knowledge in less than a day. I think it will be quite easy for you? ^^ I'm trying to create for android platform and dont mind what program u use cocos, unity...., Will you be interested? I do pay upfront LOL
quinnavery
CC BY-SA 3.0
2016-05-08T17:10:20.763Z
if u are interested, plz let me know and we can proceed to further negotiations via email or something. I can pay you via paypal just to let ya know~
quinnavery
CC BY-SA 3.0
2016-04-28T19:49:11.807Z
2016-04-28T19:49:11.807Z
Nathan Reed
<p>I'm currently trying to develop a game using Cocos2d-x using C++.
I really need to generate this burst or (donut-shaped) pulse.
I'm having a difficult time how to generate such shape.</p>

<p>At first, I was thinking of scaling the image but that didn't work out because the line or "diameter" of the donut shape gets bigger accordingly.
Any experienced coders who can provide an equation of this thing? or maybe "mathematics" is more exact.</p>

<p><a href="https://i.sstatic.net/t5yOY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/t5yOY.png" alt="c++ code sample"></a></p>

<p><a href="https://www.youtube.com/watch?v=ewnEE5mt1ZM" rel="nofollow noreferrer">https://www.youtube.com/watch?v=ewnEE5mt1ZM</a></p>

CC BY-SA 3.0
2016-04-30T01:21:28.413Z
It seems you have the answer you need, but if you ever want to look up the mathematics for anything else, the 2d donut-like shape you describe is called an [annulus](https://en.wikipedia.org/wiki/Annulus_%28mathematics%29)
trichoplax is on Codidact now
CC BY-SA 3.0
2017-04-28T08:16:17.977Z
Please don't post screenshots of code. It's not searchable and it prevents other people pasting your code into their own editor to test it.
Dan Hulme
<c++><2d><mathematics>
Generate this kind of 2d burst or pulse algorithm?
quinnavery
# Generate this kind of 2d burst or pulse algorithm?

(Asked by: username_0 on 2016-04-28)

I'm currently trying to develop a game using Cocos2d-x using C++.
I really need to generate this burst or (donut-shaped) pulse.
I'm having a difficult time how to generate such shape.

At first, I was thinking of scaling the image but that didn't work out because the line or "diameter" of the donut shape gets bigger accordingly.
Any experienced coders who can provide an equation of this thing? or maybe "mathematics" is more exact.

[![c++ code sample](https://i.sstatic.net/t5yOY.png)](https://i.sstatic.net/t5yOY.png)

<https://www.youtube.com/watch?v=ewnEE5mt1ZM>

**Tags:** c++, 2d, mathematics

> **Comments:**
> **username_1**: It seems you have the answer you need, but if you ever want to look up the mathematics for anything else, the 2d donut-like shape you describe is called an [annulus](https://en.wikipedia.org/wiki/Annulus_%28mathematics%29)  
> **username_2**: Please don't post screenshots of code. It's not searchable and it prevents other people pasting your code into their own editor to test it.  

---

## 1 answers

### Answer by username_3 on 2016-04-28. Score: 7 | Accepted answer

Rather than using an image, I would suggest doing this kind of effect using a shader. I'm not familiar with Cocos2d-x, but some quick googling suggests that it can work with shaders. You'd use a pixel shader that calculates the distance of each pixel to the center of the pulse effect, then applies a function based on that distance to define the shape and appearance of the pulse.

I made a [quick shadertoy](https://www.shadertoy.com/view/MdtXWX) as a proof of concept and example.

![enter image description here](https://i.sstatic.net/49koo.png)

> **Comments:**
> **username_0**: Hey thanks a lot for sharing ur knowledge. I wrote a code but it seems to have some error ive edites the post with an image. I would appreciate if u cab give me help with that. Im constantly running into problems so i searched for ur contact number cuz i cant post image in a comment lol.  
> **username_3**: @username_0 ...did you just copy/paste the shadertoy into your code? :D You're going to need a bit more plumbing than that. It's written in GLSL, not C++, which is where most of the errors are coming from. If you're not familiar with using shaders in Cocos2d-x, you should look up some tutorials on the subject first, such as [this one](https://www.raywenderlich.com/10862/how-to-create-cool-effects-with-custom-shaders-in-opengl-es-2-0-and-cocos2d-2-x).  
> **username_0**: hi, Im having some trouble with my developer.... he really doesnt know how to code (Just my opinion) I'm considering to hire somebody else to create the game for me. You really seem like you can code since u shared your knowledge in less than a day. I think it will be quite easy for you? ^^ I'm trying to create for android platform and dont mind what program u use cocos, unity...., Will you be interested? I do pay upfront LOL  
> **username_0**: if u are interested, plz let me know and we can proceed to further negotiations via email or something. I can pay you via paypal just to let ya know~  

---

