Having a User Drag Actors

Conifer_AppsConifer_Apps Member Posts: 100
edited December 2013 in Working with GS (Mac)
Alrighty - I'm not completely positive that this question hasn't been asked before, but I'm not sure. Before I explain the problem, I'll explain what I need to happen. When a user of this game clicks a button, an actor is spawned. The user can then drag the actor to where they want it. When the "GO" button is pressed, gravity is enabled and the actual game part of my game is commenced.

What I need to happen is I need a way to have the user be able to manipulate this actor's position on the screen. Essentially, the user is dragging a square actor around. How can you constrain two attributes' X and Y values to that of the position of a finger? Thanks so much! :-) =D>

Best Answer

  • tatiangtatiang Posts: 11,949
    edited December 2013 Accepted Answer
    The place to start would be Googling drag actor gamesalad. But I'll go ahead and give you a head start:

    When touch is pressed
         Constrain self.Position.X to game.Mouse.Position.X
         Constrain self.Position.Y to game.Mouse.Position.Y

    (game.Mouse.Position attributes are in the Devices section of the attribute drop-down menu in the expression editor.)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Answers

  • Conifer_AppsConifer_Apps Member Posts: 100
    @tatiang , thanks! I feel like a complete idiot now... At one point I even tried spawning something to the tune of 1000 actors in a grid formation and when a finger's touch is inside it is what constrains those attributes. Needless to say I had memory issues. I guess I should have acquainted myself with all the variable data gamesalad collects. I'm assuming that the mouse coordinate thingy works for touchscreens/fingers as well? Thanks again.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Yes, it works for touch/tap or mouse clicks. iPhone users everywhere will thank you for not spawning 1000 actors for their touch controls. :p

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.