2

I am making a game in which you shoot a ball. I want there to be a line that follows your finger when you touch the screen (showing you the path the ball will travel). It needs to be straight, and also a little side question:

Once the line is drawn, is there a way to detect if it collides with a sprite? So, if the line hits a wall, it won't go through it? Any help is appreciated, Thanks!

4

1 回答 1

2

for drawing only a line you can use ccDrawLine function and you can change line color using glcolor4f you can also change line width using glLineWidth but iprefer to use these functions for debug purpose. it's better if you try some sprites drawing for accual game.

for collision testing I suggest you use box2D and create body(and fixture) for both line and moving sprites. you can edit fixtures you created when ball changes position.

于 2011-06-11T23:32:30.227 回答