I’m trying to have a ball draw a path as it moves along. Currently the ball is being moved with a body:applyForce, but I have no idea how you would also draw a line of its path. Anyone have any ideas? [import]uid: 39611 topic_id: 6901 reply_id: 306901[/import]
call a function in your enterFrame (or alternatively a timer) that measures that checks the position of the ball (i would store them in an array) and then draw a line from the last position to the new position. the more often you sample the points the smoother your curve will be.
[import]uid: 6645 topic_id: 6901 reply_id: 24141[/import]
@rarussell You do mean “as it moves” and not “it will move”?
I ask because @jmp909 is quite right - an enterFrame listener allows you to draw a dot or line to a display group at the position the ball is at.
If, however, you want to know where the ball will be, for example if you want to plot the trajectory ahead of time, that’s tricky… [import]uid: 8271 topic_id: 6901 reply_id: 24164[/import]
Thanks. I am brand new to this and somehow missed the enterFrame event. That’s what I needed. [import]uid: 39611 topic_id: 6901 reply_id: 24574[/import]