How do I set boundaries to a drag and drop object

Get help using Construct 2

Post » Thu Nov 05, 2015 12:08 am

Hey! Its me again!

So, I am having some troubles on a "shop menu" programming.

What I want, is that this shop menu is able to be dragged to show more itens that were "hidden" outside the layout, and it worked. BUT how do I set a boundarie, so the player won't be able to take the menu out of the layout.

Here a project were I put a backgrouns and some "buttons" and they show what I did so far. "https://www.dropbox.com/s/zvm1d1qte6ppx7y/Test.capx?dl=0"

Waiting for your help buddies!
B
6
S
1
Posts: 13
Reputation: 376

Post » Thu Nov 05, 2015 3:02 am

I can't open your capx right now, but you could use the clamp() expression to set the menu's position when dragging and on drop.
B
92
S
32
G
106
Posts: 5,273
Reputation: 69,457

Post » Thu Nov 05, 2015 5:52 pm

R0J0hound wrote:I can't open your capx right now, but you could use the clamp() expression to set the menu's position when dragging and on drop.


What do you mean "clamp expression"? Never heard of it.
B
6
S
1
Posts: 13
Reputation: 376

Post » Thu Nov 05, 2015 6:07 pm

https://www.scirra.com/manual/126/system-expressions

clamp(x, lower, upper)
Return lower if x is less than lower, upper if x is greater than upper, else return x.

so you could clamp the x-position of the sprite by:

sprite set x = clamp(sprite.x,100,200)

the x-position of the sprite can only be between x=100 and x=200 this way..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: Lancifer, nahima, OddConfection and 18 guests