...make sprite scroll to mouse

Get help using Construct 2

Post » Tue Nov 29, 2011 7:47 pm

Hello peoples,
I am making a strategy game and how could I make it so when the player right clicks the object 'sprite' move towards the mouse position?

I know how to make it jump to but not scroll

-Many thanks
B
13
S
2
G
4
Posts: 54
Reputation: 3,882

Post » Tue Nov 29, 2011 8:27 pm

What I would do is create a small invisible sprite at the point you click. Then set the object sprite (whose behaviour is a bullet???) from speed 0 to speed 2. Then if object hits sprite, set the speed to 0.

That's what I would do :)
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Tue Nov 29, 2011 8:34 pm

You could use the "mouseto" behavior (from the plugins forum) and set it to mouse.x, mouse.y.

You can check also in the How do I FAQ there's a few other implementations proposed in the section "object moving".
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Tue Nov 29, 2011 9:00 pm

I would create 2 variables moveToX and moveToY and define them when the player clicks, for instance:

On player Left Click -> set moveToX = Mouse.X; set moveToY = Mouse.Y
Do intended action here

You can make a global variable or a local variable or instanced variable; whichever you prefer.

You'll have to set the variables back to 0, however otherwise you would have some weird things happening lol.

If you look at my post ProjectDL and play the game you will see that it works.

Moving to the targeted object should be simple, I think there is a move to action; I'm at work right now and cannot verify.kiasta2011-11-29 21:02:15
B
3
G
1
Posts: 12
Reputation: 599


Return to How do I....?

Who is online

Users browsing this forum: austinblackbelt, spcsmrf and 10 guests