Old man needs a simple answer ... click and centre a 2048x2048 actor on the clicked/touched spot

DaveyJJDaveyJJ Member Posts: 12
edited July 2012 in Working with GS (Mac)
I'm not sure I understand the X/Y co-ordinate system used in Gamesalad.

I have a scene set to iPad landscape mode and an actor who is 2048x2048 pixels ("move-radius", a simple 10Kb slightly opaque black ping with a 512 pixel circle cut out of the middle, that will be used to indicate how far a clicked piece can move, and obviously extends out well past the edges of the scene). I have some round checker pieces in the scene. I am able to get the game to, when I click a piece, make the move-radius piece alpha go to 1 to show up; and then disappear when I stop dragging the piece. Lovely.

My problem -> For some reason I can not figure out how to make move-radius *centre itself where the mouse was clicked*; that is 1024 pixels right and down from it's own top left corner. The centre point of the cut out circle should appear right where I clicked.

How do I make that happen? Thanks from an old guy.

Comments

  • 3itg3itg Member, PRO Posts: 382
    edited July 2012
    Actors are measured from their center in gamesalad, so you got the centered part covered by default.
    Make 3 game attributes for the location. One X, One Y and a Boolean.
    Make a rule on the actor that you want to move "when mouse is clicked, change One X to mouse.position.X" and "when mouse is clicked change One Y to mouse position Y"
    And directly following those rules change your boolean to "true".

    Now another rule...
    When Boolean = true
    Change attribute self.position.x to One X
    Change attribute self.position.y to One Y
    Change Boolean to false, end rule.

    You might want to use constrain attribute rules depending on your desired behavior. But that should give you a good start. Let me know if it helped
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    You don't need any extra attributes for this. In the circle cut out actor put this rule

    When mouse button is down
    -- constrain attribute self.position.x to mouse.position.x
    -- constrain attribute self.position.y to mouse.position.y

    That will make it follow your mouse or finger where ever it goes.

    Now if you don't want it to follow and instead just snap to where it's at you can use change attribute instead of constrain.

    Cheers
    Aaron
  • DaveyJJDaveyJJ Member Posts: 12
    Thanks to both. Aaron, when I use the change attribute as shown above on a small actor (say, 100x100px) this works fine. On the bigger actor, a 2048x2048px square with the circle cut out of the centre, it refuses to centre when I click. And there appears to be no rhyme or reason as to how it positions itself. Thoughts? I can post the very small sample to show.
  • DaveyJJDaveyJJ Member Posts: 12
    edited July 2012
    I posted the file in case someone else can figure out what I'm doing wrong.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    No idea why its not working for the larger Actor. Your download link doesn't work.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    I have no issues making it do what I think you are wanting. Heres a project file to look over.

    Cheers
  • DaveyJJDaveyJJ Member Posts: 12
    Thanks, tenrdrmer, your help file works fine. I will tinker with mine and keep trying. I'm doing something wrong, obviously.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    In your Circle Actor Both of your change attributes are changing the self.position.x value of the actor. You need to change the second one to self.position.y and it works fine.



    Also I'm removing your download link from above so you don't get to many people downloading your entire project with less than honorable intentions.

    Cheers
  • DaveyJJDaveyJJ Member Posts: 12
    In your Circle Actor Both of your change attributes are changing the self.position.x value of the actor. You need to change the second one to self.position.y and it works fine.

    Also I'm removing your download link from above so you don't get to many people downloading your entire project with less than honorable intentions.

    Cheers
    D'oh! Thanks from this dyslexic old man.

Sign In or Register to comment.