Making "self.CantDrag" happen when actor is over a set x-y spot
QuiziCat
Member Posts: 12
I'm making a very simple jigsaw for kids- thanks to the forum I can now Make the actor drag when "touch is pressed" with
"self.CantDrag <1" and can make it lock my using" touch released" with change attribute "self.CantDrag to 1"
There MUST be a simple way to make the change attribute "self.CantDrag to 1" happen when the actor is over the spot "Constrain attributes set to x and y axis " to the jigsaw piece. Does anyone know how please? I'm an animator NOT a programmer which is why I'm using GS
"self.CantDrag <1" and can make it lock my using" touch released" with change attribute "self.CantDrag to 1"
There MUST be a simple way to make the change attribute "self.CantDrag to 1" happen when the actor is over the spot "Constrain attributes set to x and y axis " to the jigsaw piece. Does anyone know how please? I'm an animator NOT a programmer which is why I'm using GS
Comments
Perhaps the easiest way to do this is to create a new actor that has the same graphic as the moveable puzzle piece -- but does not have any behaviors.. Then when the movable puzzle piece is in the right spot, you can spawn the new actor and destroy the old (moveable) one. Since the new actor has no movement behaviors, it will just sit there -- just like you want.
http://arcade.gamesalad.com/g/117455
however I really want to try to understand what is going on for myself so this has NOTHING to do with his template now - Is there a way of actually showing you how I am attempting your suggestions in GS ? I'm sure it's just some daft thing I'm NOT doing that would immediately be obvious to you.. cheers Sheila
RULE
Actor receives event - touch is pressed
Attribute self.CantDrag <1
Constrain attribute self.position.x to game.Mouse.Position x
Constrain attribute self.position.y to game.Mouse.Position y
That's it .. I have the co-ordinates of the place it is to go to.. and I've tried creating another actor .. then all sorts of ways to add those measurements and then spawn and destroy. If you could kindly list in a simple way - as I have above- what to do - I'm sure it will work and I can get on with the animation - which is what I'm really about - if ever you need a character animating - I'd do it as a swap!
I'd do it simply by checking whether the jigsaw piece is in the right location when the mouse button (or finger on touch devices) is released.
A basic check . . . like this:
Let's say the jigsaw piece needs to sit at x600, y400 . . . but you want to give your player some leeway, so they don't have to place it on the exact pixel, let's give them 50 pixels leeway in each direction . . .
Your rules would look something like this:
When mouse button is released - and
The jigsaw piece's x position is > larger than 550 and < smaller than 650 - and
The jigsaw piece's y position is > larger than 350 and < smaller than 450
>>>Then:
Interpolate the jigsaw piece's x position to 600 - and
Interpolate the jigsaw piece's y position to 400
Hold on, let me make you a quick example file . . .
File: http://www.mediafire.com/download/ksc66rf8w3ssya6/J001.zip
Basically when the jigsaw piece collides with the detector - it interpolates to the correct position, this method saves you having to type in the co-ordinates for each piece - also you can change the size of the detector - a smaller detector would mean the player has to place the piece more accurately.
File: https://www.mediafire.com/?261nunwt31y79jn