Nooby Question how to use Touches to move up then when letting go of the touch move down

Synlight DevelopmentSynlight Development Member Posts: 3
edited March 2013 in Working with GS (Mac)
Hey there guys!

As I finish up on my first GameSalad game (thank you all for the help in learning) I'm trying to finish my controls. I would like to move the actor up upon touching the screen then when letting go the actor falls down. As well as figuring out how to keep them from going off the screen. Now iv used the move with touch to move up but getting the actor to stay on the screen as well as come down is my troubles. Just looking for a direction to move with I don't mind playing with it from there.


Thanks in advance!

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2013
    When Touch is Pressed
    .....Constrain Attribute self.position.Y to min(game.mouse.position.Y,768-self.Size.Height/2)


    *768 is the scene height.

    And if you also want to constrain to the bottom of the scene, change it to:

    When Touch is Pressed
    .....Constrain Attribute self.position.Y to max(0+self.Size.Height/2,min(game.mouse.position.Y,768-self.Size.Height/2))

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

  • I may be doing this wrong but when I add in the above im having a few problems.

    1. Only if you touch the plane will it move up

    2. When the plane is touched it is still going off of the scene

    3. When releasing the touch the plane is not going down

    Not sure if I am entering that wrong


    Thanks!
  • PaxPaxPaxPax Member Posts: 106
    edited March 2013
    Here are some comments. Difficult without seeing what you coded.

    1. isn't that what you wanted?
    2. height of 768 is for iPad---adjust if you are using iphone or whatever
    3. do you have a 'when touch is released' rule---(touch pressed go up and touch released go down)

    cheers





  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I sent a PM with a demo, but I'll post it here as well.

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

Sign In or Register to comment.