I'd like to make a function that allows the user to draw a path from a sprite for the sprite to follow it.
Long ago, I found a .capx that does almost that. I tried to modify it but could make it work only when I draw the line from the front of the sprite.
See for yourself, capx is included in the link. Hope you'll be able to make it work right
Thanks !
Laurent
https://www.dropbox.com/s/kenyke42fe51w ... .capx?dl=0
Anyone ?
Unfortunately can't open the link you are referring to.
I tried to modify it but could make it work only when I draw the line from the front of the sprite.
Where do you want to draw the line from? In order for the sprite to follow the line, it would need to originate from the sprite at some point.
If that doesn't work then I think there was a change in C2 that caused it not to work. However there should be a fix in the topic it came from as I recall.
Alternatively this also works:
mouse: left button down --- create dot at (mouse.x, mouse.y) for each dot ordered by dot.zindex ascending --- sprite: set angle toward (dot.x, dot.y) system: compare distance(sprite.x,sprite.y,dot.x,dot.y)<sprite.bullet.speed*dt --- dot: destroy else --- stop loop[/code:2r77i6tp]
Develop games in your browser. Powerful, performant & highly capable.
The file has been created with the last version of the beta
If that doesn't work then I think there was a change in C2 that caused it not to work. However there should be a fix in the topic it came from as I recall. Alternatively this also works: mouse: left button down --- create dot at (mouse.x, mouse.y) for each dot ordered by dot.zindex ascending --- sprite: set angle toward (dot.x, dot.y) system: compare distance(sprite.x,sprite.y,dot.x,dot.y)<sprite.bullet.speed*dt --- dot: destroy else --- stop loop[/code:2tuualvn]
mouse: left button down --- create dot at (mouse.x, mouse.y) for each dot ordered by dot.zindex ascending --- sprite: set angle toward (dot.x, dot.y) system: compare distance(sprite.x,sprite.y,dot.x,dot.y)<sprite.bullet.speed*dt --- dot: destroy else --- stop loop[/code:2tuualvn]
Thanks — for the quick answer. But unfortunately, it doesnt seem to be working either.
Naw, it works:
https://dl.dropboxusercontent.com/u/542 ... _line.capx
Thanks, R0J0. I'll try to find a way to prevent the box to move continually
Can be done easily.
Set initial speed of bullet sprite to 0.
When mouse down - set speed to 200.
When dot.count = 0 -> set bullet speed back to 0.
> Thanks, R0J0. I'll try to find a way to prevent the box to move continually > Can be done easily. Set initial speed of bullet sprite to 0. When mouse down - set speed to 200. When dot.count = 0 -> set bullet speed back to 0.
> Thanks, R0J0. I'll try to find a way to prevent the box to move continually
>
Lovely !
Thanks