Making "self.CantDrag" happen when actor is over a set x-y spot

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

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    There are several ways to do this -- each with its own advantages and disadvantages.

    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.
  • QuiziCatQuiziCat Member Posts: 12
    Thankyou so much for kindly taking the time - and expertise to reply so quickly - I have tried what you say and I"m sure if I did it in the right way it would work - I've only been doing GS a week and on my arcade site is Quizicat and Bones which shows how far I got with the template from TshirtBooth
    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
  • QuiziCatQuiziCat Member Posts: 12
    This is the rule I have on my moveable actor which is to fit into the jigsaw position.

    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!
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2014
    @QuiziCat

    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 . . .
  • SocksSocks London, UK.Member Posts: 12,822
    Here you go, drag the square on the left around to place it in the right place, when you are with in 50 pixels of the target - and you release your mouse - the jigsaw piece will settle into the correct position . . .

    File: http://www.mediafire.com/download/ksc66rf8w3ssya6/J001.zip
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2014
    Here's an even simpler method using a 'detector'.

    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
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    What @Socks said! (I did mention that there are plenty of ways to do this.)
  • QuiziCatQuiziCat Member Posts: 12
    Socks thanks so much for your example files..REALLY nice artwork by the way - I followed J001 in my own way and got it to work fine thanks. However when I followed J002 the piece just would not move at all - I noticed that in j002 there are no rules for actually moving the mouse and YET yours works fine..How is that ?? I tried adding drag rules.. but no go. I am still at a VERY simplistic level - so I'm sorry that your help and that of RThurman are just not working for me. All the concepts of dragging a piece and slotting into position are there from you both thanks ... I just can't get them all to work together
  • QuiziCatQuiziCat Member Posts: 12
    Hi Socks - just spotted the "otherwise' in you file J002 - just works GREAT - and now I know how to fit in RThurman's suggestions about destroy and spawn.. so thanks to you both. Good luck with your own GS work
  • SocksSocks London, UK.Member Posts: 12,822
    @QuiziCat
    .. so thanks to you both
    Glad it worked for you. :)>-
Sign In or Register to comment.