How to check if a touch is in the box?

digletodigleto Member Posts: 76
edited November -1 in Working with GS (Mac)
I have a ball and a box. I move the ball by touch. I only want to be able to move the ball if I touch inside the box. I cant seem to figure out how to check if the touch is inside the box or not... help?
Thanks in advance :)
-Digleto

Comments

  • HunnenkoenigHunnenkoenig Member Posts: 1,173
    Simply add a rule to to the box:
    If touch inside
    change attribute game.whatever to 1

    and on the ball:
    if attribute game.whatever = 1
    AND
    if touch
    do whatever you want
  • digletodigleto Member Posts: 76
    Yes, I can do that. My question is how to check if the touch is inside the box or not, sorry I did not make that clear
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    do exactly what Hunn said.

    add to your rule, if touch inside.

    you have a ton of touch rules: pressed, released, inside, outside

    so to make sure you're only touching the ball when it's inside the box, create a global attribute called boxTouched or something.

    then on the box, just like Hunn said, put:

    if touch is pressed and touch is inside
    change game.boxTouched to True

    and on the ball:

    if game.boxTouched is True
    [put game logic here]
Sign In or Register to comment.