How do I hold a sprite with the mouse moves?

Get help using Construct 2

Post » Thu Oct 02, 2014 4:39 am

How do I make a simulation of how to pick up an object? for example: a chess game!
In short I need:
1 - first click - grab and hold the piece
2 - the piece follow the same place the cursor across the board like a ghost
3 - second click - drop the piece

I guess that is how to became the cursor on the piece until release it on right place of the play.

Thanks for the support!
B
7
Posts: 6
Reputation: 296

Post » Thu Oct 02, 2014 4:48 am

Add the drag & drop behavior.

EDIT: oh, but you don't want to drag it.. you could toggle a boolean instance variable (state) which tells it whether or not it's dragging.

like, on click sprite, toggle boolean variable.

if variable true set sprite position to mouse.x, mouse.y
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Fri Oct 03, 2014 1:56 am

oh buddy I forgot to say the point of my problem
sorry!!!
to be clear I tried to move the sprite together to cursor after RELEASE the mouse button.
in other words
move mouse = move sprite
without hold any button
B
7
Posts: 6
Reputation: 296

Post » Fri Oct 03, 2014 1:58 am

I think what I told you should work. unless I'm not understanding you. (I think you mean drop, not large)

If you're not dragging it, don't use drag & drop.

I'll try to be more clear. and maybe I'm just misunderstanding.

Give the piece an instance boolean variable. call it "hold", set it false.

1.
On piece clicked, toggle "hold"

2.
If "hold" = true, set piece position to mouse.x, mouse.y.

3.
(no code necessary) next click will set "hold" to false and it will no longer stay with the mouse cursor.

I'm not sure why you want to destroy and recreate the piece if you're just moving it?

Hope that helps!
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Tue Jan 20, 2015 11:01 am

You can visit my Chess board made with Construct 2.

Don't forget skip add.
Check it out:

Sorry, if you want the link, please private.
Last edited by PepeCharlie on Tue Jan 20, 2015 11:03 am, edited 1 time in total.
B
2
Posts: 1
Reputation: 154


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 12 guests