dynamic drawing in cocos2d? - drawing

I am working on a game which would take touch gestures as inputs. Now, i would like to display the path/gesture as the user draws it. Can someone please tell me how to do this in cocos2d?
I tried to override the draw method and used ccDrawPoint(). But the point just keeps following the touch. I guess this is because the previous drawing is getting overwritten.
Can you tell me where i am going wrong here or suggest a better way to implement this?

i found a solution with CCRenderTexture sample test in cocos2d. Though i could not find enough documentation on it, but the sample code is enough for a start.

Related

Best way to have animated background in cocos2d

I have seen some similar questions asked but no definitive answer.
I have a background image that I'm using for my main menu for a cocos2d game. I plan to have it animated but not sure what is the most efficient way to do this. One idea was to have multiple images to create the animation but I was thinking this may take up too much memory as each image would be quite big.
The other idea was having one background image as a sprite and then having child sprites of that image that are animated with ccaction. The only thing is I may not be able to create such an elaborate animation if I do this.
I just wanted to get some feedback on this to see what would be the best approach.
Thank you,
Making a frame-by-frame animation of the whole screen would make your app size litteraly explode.
You should definitely go with your 2nd idea, i.e have different sprites for each animated component and use actions to animate them.
Check out CocosBuilder: it provides a nice UI for designing such complex animations

Printing string and variables to glwindow

I have been looking to an answer to this for a while now but I can't really find one.
I'm not using glut so please no glut only answer.
What I am trying to do is send variables and text to the in game screen so I can make an UI with a little feedback for the player, like the amount of money they are carrying at that moment. (So not the debug screen)
I'm using c++ with opengl.
If I need to provide anyone with more information, please ask and I will do my best to provide you with it.
Thank you in advance.
If you can live with GL1.x, use the classic reference on bitmap fonts: http://nehe.gamedev.net/tutorial/bitmap_fonts/17002/
If you need something relevant, modify the sample above to use Vertex Arrays / Vertex Buffer Objects and not the glRasterPos functions.
Advanced way is to use the FreeType to render truetype fonts. Here's a sample.

Coloring application using Cocos2D

I trying to make an empty CCSprite then I want to hand drawing on it using touch controls.
But, I don't have an idea how make it and don't know it's possible.
So, PLS help me or give me some advice.
Thanks
I wrote a demo program for CCRenderTexture which shows you how to draw sprites (or whatever you want) with touches:
Hi You can use CCRenderTexture example from Cocos2d for drawing..
Check out this link http://www.cocos2d-iphone.org/forum/topic/8474

Redrawing the screen and wiping what was already there

I need some help - I'm trying to create a roguelike using C++, and at the moment, I have a very simple little screen going, with a void() that generates a map, using "#" for walls and "." for floors. It can draw the player by comparing some integers which map the X and Y values of the player.
I even have a little HUD which will display the player's stats.
But, the issue is, this is all being designed using a typical command-console window, and I'm starting to think I'm doing this wrong.
I want the player to move around this big empty room I have, by using the numpad -- this works. By using a Switch, I adjust the X and Y player value and then redraw the screen again.
Here's the issue. This actually redraws the screen all over again: it adds the 20-odd lines all over again, every single time I move. After a few moves, I have a command console window with text going for hundreds of lines.
So what am I doing wrong? Is there a command I don't know about to clear the screen?
Or am I doing this wrong from the start -- for instance, you have to press 'enter' to input your command, something that's not in any other roguelike. I'm a novice programmer, so any and all help is appreciated!
Thankyou!
Edit: Okay, thanks guys, I am now using PDCurses and trawling the docs to work out how to use the thing! Thanks again so much! Somebody please give the guy who suggested this a big tick! :D
What method are you using to draw the screen, just normal iostream? For this kind of work a library called curses is normally recommended. It would let you draw text anywhere on the screen without scrolling or redrawing the entire screen.
I don't know of any reliable way to do it with portability, maybe try looking for some console oriented lib... Anyway under Windows you can still use system("cls");
You can use the ansi escape sequence: printf ("\33[2]").

How to handle audio-card buffer

Im trying to do a screen-flashing application that flashes the screen depending on the audio(like an audio visualizer, but instead of a visualization like bars or something like that, just flash the screen).
I already made the music player and know how to make the widget get full screen and change color(which will flash), but I dont know how to detect the (I think it's audio-card)buffer is full, because when it is full I would change the color of the widget, and this would be really super fast, so the screen flashes super quickly.
Any ideas on how to detect if the buffer is full, or any other approach I might pursue to achieve my goal?
Thanks beforehand.
Have you checked the SoundMixer Class computeSpectrum method? It doesn't give you a buffer info rather it returns info about the sound being played that you can use in order to represent the sound graphically.