Axis constraint during Drag and Drop

Get help using Construct 2

Post » Mon Apr 22, 2013 9:36 pm

I'd like to constrain objects to the X axis while dragging on the screen with Touch. I've tried several of methods suggested on this forum but have yet to find a simple solution that works. Any tips would be greatly appreciated. Thanks in advance!
B
3
Posts: 5
Reputation: 185

Post » Mon Apr 22, 2013 9:44 pm

A relatively simple way to do this would be to give the sprite an instance variable called FixedY (or whatever you want). Then create these two events:

On Sprite created -> set Sprite.FixedY to Sprite.Y

If Sprite.Y > Sprite.FixedY [OR] If Sprite.Y < Sprite.FixedY -> Set Sprite.Y to Sprite.FixedY.

It's quick, but I would really appreciate it if this functionality was built in though.
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Mon Apr 22, 2013 9:52 pm

or
on Trigger -> set Sprite.FixedY to Sprite.Y
every tick -> Sprite.Y set to Sprite.FixedY

ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Mon Apr 22, 2013 10:39 pm

Awesome suggestions, thanks! I'll try them now and report back
B
3
Posts: 5
Reputation: 185

Post » Mon Apr 22, 2013 11:49 pm

Okay, I've been a 3D artist in the video game industry fro over a decade but this is the first time I've ever tried my hand at any type of coding and am stuck.

I've added the Instance Variable called FixedY to my sprite and set it up as Boolean, Initial Value:False...and them I'm lost

I've gone into the Event Sheet and added the sprite I created the variable for but am not sure of the Condition to set as there are no options showing for FixedY? I'm sure this is a total beginner question but that's exactly what I am (just purchased Construct yesterday) Thanks again!

B
3
Posts: 5
Reputation: 185

Post » Tue Apr 23, 2013 12:02 am

Boolean have only two state - true or false.
You need to set Your variable FixedY as a number variable.

Here is a link to the manual about instance variablesshinkan2013-04-23 00:03:41
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170


Return to How do I....?

Who is online

Users browsing this forum: Artpunk, Axiomaltd, MACPK, nicklowkcmagic, OddConfection, Yahoo [Bot] and 22 guests