Make a DragDrop Behaviors Scope?

Get help using Construct 2

Post » Sun Jul 21, 2013 9:18 am

Hi,
I am make some object can Drag Drop in my game
However,It can move everywhere in layouts
How to set move Scope?

Thankblueman3212013-07-21 09:23:39
B
6
Posts: 9
Reputation: 443

Post » Sun Jul 21, 2013 10:00 am

Hi @blueman321,

All you need to do is add 'Drag & Drop' behaviour to the objects you want to move around. I've added a simple example (DragDrop.capx).

If you want to limit its movement to certain areas, just use this example by Yann (limited movement example)

Hope that helps :)
B
33
S
6
G
7
Posts: 494
Reputation: 8,252

Post » Sun Jul 21, 2013 12:45 pm

Thank @Blacksmith,
(Sorry for my poor English)
I am reference the limited movement capx,

but it have lot of bug of my game....

I want to create Scope without extra object,

I change the expressions:

clamp(self.X,square.BBoxLeft+self.Width/2,square.BBoxRight-self.Width/2)
To
clamp(self.X,self.X-20,self.X+20),But it is not work

It is wrong at first(self.X)

How can I get the original X of object ?blueman3212013-07-21 12:48:24
B
6
Posts: 9
Reputation: 443

Post » Sun Jul 21, 2013 1:47 pm

@blueman321,

Not sure I fully understand what you want to do. If you are moving your object, then its self.X will always be changing, so it wouldn't be very useful to use that within the expression.

If you want to limit the movement of your object to just +/- 20. You could still use Yann's example. Just create an invisible sprite/box, which is 40 pixels bigger than your object. Then use the clamp expression from the example.

Edit: If you want to record the original x of your object, you can put the value into a variable. Then use that var as a reference for objects original position.

But I think Yann's method would work best.

Blacksmith2013-07-21 13:52:35
B
33
S
6
G
7
Posts: 494
Reputation: 8,252


Return to How do I....?

Who is online

Users browsing this forum: Ajbael, Darknessed and 9 guests