I'm trying to imitate the drawing of lines in a certain iOS game on cocos2dx,

The way i chose to implement it is by creating a dynamic cubic bezier curve. For that, i will have to get 4 x-y screen locations:

1) begin point

2) control point 1

3) control point 2

4) ending point

As for the begin and end points, it's obvious i should use onTouchBegan and onTouchEnded and retrieve the relevant locations.

Since the line should be drawn immediately meaning, not drawing the non processed line and then process it, but creating a temp bezier curve at any time, i don't really know how to approach it and create the curve.

onTouchMoved(cocos2d::Touch *Touch, cocos2d::Event *Event)

is the problematic part, how do i determine the relevant control points?

any suggestions or ideas for different implementation will be welcomed.


Related posts

Recent Viewed