Touching Different Parts of an Actor

Hi, I just downloaded gamesalad a couple of hours ago so I'm fairly new and was wondering if someone could help me out. I have a scene with gravity enabled and an actor falling because of it. I set it up so that when the actor is touched, it increases its velocity 90 degrees upwards, then shortly after starts to fall again because of the gravity. Just wondering how I can make the direction in which the actor changes velocity relative to where the actor is touched. For example if it is touched on the bottom it will go up or if it is touched on the side it will change velocity towards the opposite side.

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited August 2013
    In my keep it up game just released I'm using this expression

    Kick Angle = ((120/100)*((100/self.Size.Width)*(game.Touches.Touch 1.X-(self.Position.X-(self.Size.Width/2)))))+30

    Now let me try and explain it

    I want the ball to only ever go up between the angles 30 and 150, so I delete 30 from 150 to get 120 and then I get it ready to calculate percentages

    (120/100)

    I'm then working out how far left in percentages the ball was touched

    ((100/self.Size.Width)*(game.Touches.Touch 1.X-(self.Position.X-(self.Size.Width/2))))

    I'm taking the far left position of the ball with centre of ball - (ball width / 2) away from the screen position of the tap. I take into account of the screen position tap because without it you end up pushing the ball down when it's rotated.

    Then I'm adding 30 to end of the number so that the final angle is between 30 and 150

    I did originally have rules if pressed within the left side of the ball then send it off randomly at a rightish angle and if pressed in the centre send it up in a randomish angle etc. but figured one expression might work quicker and the player would have better control of the ball because it's not being sent off randomly
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited August 2013
    I've placed a simple project on my site here: http://www.kevincross.co.uk/?attachment_id=55

    It doesn't contain any game logic like lives and scores. It only contains 2 walls, 1 floor, and a ball which has the above Kick Angle formula attached to it.

    I use Touch Inside, rather than Pressed because with Touch Inside it allows you to hold your finger down on the screen and move it around under the ball similar to a table hockey game, and it also allows you to flick the ball up.
  • sethmansethman Member, PRO Posts: 15

    This is awesome. Not exactly what I was looking for but gives some insights anyways. Thanks for charing!

Sign In or Register to comment.