Saturday, November 17, 2018

iphone - Creating 2D waveform for Cocos2d game


I'd like to have a Waveform in my iPhone game that I am developing using Cocos2d v2.0.


Example Waveform


That's the ideal wave I'd like to achieve. A simpler wave which I would still be happy with is this one.


Example 2


Some people suggested me to use ParticleEffects ands ParticleDesigners like 71squared but I am not sure that this is the right approach.



Brainstorming, I think that at the end a wave is a plot of some function, and at each frame translate the wave points that where from the origin apart (-x and +x) and computes new wave points for the origin.


Something like this:


for (duration of effect)
compute wave point intensity at origin and display it
and
for each wave point before the center translate to -x and display it
and after the center translate to +x and display it

Let me know what you think and if you have any better solution. I was thinking to achieve the display point by colouring a particular pixel but I need to figure out how :)..



Answer




I asked the question also on the cocos2d-iphone forum and someone kindly replied. I thought I would share his answer to avoid duplicate effort:


Answer


I haven't yet tried them because I am struggling deciding what to learn first ES 1.0 vs ES 2.0 as I have just migrated my code to Cocos2d v2.0 and I don't fully understand all the implications, but judging Apple's AurioTouch example posted in the answer it looks promising.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...