Move actor based on touch on either side of actor...

CaptMediaCaptMedia Member Posts: 60
edited April 2012 in Working with GS (Mac)
Hi, I am trying to figure out how to move an actor a way based on which side of the actor you press. For example, if you touch above the actor the actor goes up; if you touch below the actor it goes down.

I have implemented this rule but it only moves once:


Attribute - game.Touches.Touch 1.Y > self.position.Y

Change Attribute - self.position.Y -to- self.position.Y+50

Is there anything wrong with this rule that I am missing; or is there a better way to do this? Please help, thanks in advance!

Answers

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Try this
    Rule - if touch.1.x < self.position.X
    change self.motion.linearVelocity.X to -100

    Rule if touch.1.x is > self.position.X
    change self.motion.linearVelocity.X to 100

    If touch.count = 0 change self.motion.linearVelocity.X to 0
  • CaptMediaCaptMedia Member Posts: 60
    edited April 2012
    Hi, thanks for your quick response! I just tried this and it did not work very well. Whenever I click above the actor it does not go anywhere (I double checked both rules) but when I click below it does but a very for a very distance. I would rather have it sort of snap into position with one touch rather than glide, but I assume that can be fixed by increasing the speed. Any other ideas? Thanks
  • CaptMediaCaptMedia Member Posts: 60
    Would it be to much on the game engine if I were to constrain a controlling actor to each side of the main actor?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @CaptMedia it really depends on other factors (number of other actors, number of other constrains, etc.). I'd say try it and see if you're happy with the game speed/lag.

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

  • CaptMediaCaptMedia Member Posts: 60
    Thanks @tatiang, I just tried to do it but on my device the actor would not even move, most likely too much for the game engine. Any other ideas? thanks
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    try This

    When Mouse button is Down
    Move to mouse position x and Mouse position Y at a speed of 100

    Also it kinda frowned upon to reject peoples answers simple because it did not cover everything you wanted. You just simply reply and state it did not work quite how you are wanting. reject is really more for completely useless replies.

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Just so you know If you were going to put actors on each side to act as touch controls, you dont have to constrain them. Just put them on a non scrollable layer.
  • CaptMediaCaptMedia Member Posts: 60
    Thanks for the help @tendrmer, I did not realize that about the accept and reject options, I only rejected them so that the question would not appear as answered on the forums page. I will remember that for the future though, did not mean to offend anyone, if I did.
Sign In or Register to comment.