Page 1 of 1

Drawing Lines without using a Canvas Actor

PostPosted: Tue May 16, 2006 10:18 pm
by plinydogg
Hi everyone,

I was wondering if anyone knows how to draw a line between two actors without using a canvas.

For example, let's say you've got some moveable units and you want to let the user set their destination when they are tapped on with the stylus (and you also want to let the user check on a given unit's destination by clicking on it). The most obvious way to do this is by drawing a line from the unit to its destination.

The only way I can think of doing this so far is by creating a canvas and setting its visibility state to "DISABLE" when it's created, and then enabling it when the user taps on a unit. But there must be a less cumbersome way right? Also, isn't the line drawn from the upper left hand corner of the event actor (which would make this approach impractical)?

Thanks in advance!

PostPosted: Wed May 17, 2006 8:07 pm
by plinydogg
No one has any idea? Really?

PostPosted: Wed May 17, 2006 9:32 pm
by twobob
The only way other than the canvas actor method I can think of is where you draw a series of dots between two actors.
If there are 2 actors A and B. On mouse down on A to draw a line/dots to B:
Create an actor called movingdot at position A and with actor movingdot do a MoveTo to position B
On the MoveTo function, also create a timer at 25 ms (change this to make dots closer or wider).
On each 25 ms on the timer, create a new actor dot (staticdot) where the movingdot is at its present position while its moving towards actor B
On the event move finish, delete the timer.
Changing the speed in the MoveTo fuction will also affect the distance of dots.

PostPosted: Sat May 20, 2006 1:08 pm
by plinydogg
twobob,

Thanks for the help, it worked more or less perfectly!