How do you . .

TheodiTheodi Member Posts: 96
edited November -1 in Working with GS (Mac)
Get an actor to bounce left and right depending where you tap on the actor?

I have the bounce left done, but making it bounce right isn't working.

The rule im using is this, If game.touch.touch1.x is less than self.position.x
then
change velocity etc.

But this isnt working for bouncing right, anyone know how to do this?

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi Theodi, what's needed here to make it work is putting a Rule within a Rule. So:

    Rule: When touch is pressed (or released)

    then this next Rule IN the first one:

    When game.touch.touch1.x is < than self.position.x
    change velocity/direction, etc.

    otherwise (the one in this second Rule)

    When game.touch.touch1.x is > than self.position.x
    change velocity/direction, etc.

    Give that a whirl.

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • TheodiTheodi Member Posts: 96
    Hi Gyroscope thanks for the help!

    It still only bounces left though, this is what i have done.

    I created a rule, and entered When game.touch.touch1.x is < than self.position.x
    change velocity/direction, etc.

    OTHERWISE

    When game.touch.touch1.x is > than self.position.x
    change velocity/direction, etc.

    Theo
  • TheodiTheodi Member Posts: 96
    Hi I just realised I didnt put the rules in a rule which is "When pressed" etc, so i just did, but still doesnt work!
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    OK, I misread your question: I see now that the tap is on the actual actor, not to the left or right outside of it. This makes it simpler. THe following, add your velocity change as you want, as well as replace move to with interpolate x if you like:

    When touch is released ---this is better than "pressed" in this instance, I've just thought---
    Move To --- in the x box: game.Touches.Touch1.X and in the Y box: the Y position of the actor, if you only want it moving horizontally.

    The other Rules would be best for a background actor to register the touches to move your moving actor - if you wanted to click outside of the actor to have it moved. Here is that again (slightly amended and using a boolean attribute called Move):

    Rule: When touch is pressed

    change attribute Move to 1

    otherwise
    change attribute Move to 0

    And then in the Rules of the moving actor:

    When attribute move is true

    Move To game.touches.touch1.x, --- the y the same as the moving actor

    Hope that does the trick now. :-)

    When game.touch.touch1.x is > than self.position.x
    change velocity/direction, etc.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • TheodiTheodi Member Posts: 96
    Im confused now! Do I make a rule with "when released move etc". ?

    What I want to be able to do is, the actor to bounce when tapped. So If the player taps on the left side of the actor, it bounces right, and if tapped on the right, it bounces left.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Sorry to confuse you Theodi; it's because I put too much info in, for other scenarios! (I tend to "overhelp" sometimes...)

    Just go with:

    When touch is released ---this is better than "pressed" in this instance, I've just thought---
    Move To --- in the x box: game.Touches.Touch1.X and in the Y box: the Y position of the actor, if you only want it moving horizontally.

    See if that's what you're after.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • TheodiTheodi Member Posts: 96
    Hi again, I tried it, it does the same as it was before, just bounces left.

    So I removed all rules that apply to it bouncing, and ran the game, it still bounces left when pressed!? How can that be? There aren't any rules telling it to.
  • TheodiTheodi Member Posts: 96
    I re started GS and it fixed. The rule you gave me doesn't do the job though.

    This is what happenes in my game and what I need it to do.

    An actor is falling down, you have to tap it to make it bounce up, and left or right (depending on which side you tapped) So it bounces in an arc, not just left or right you know?

    Right now its just traveling downwards now I took my rules off I had before.

    Another problem I had before which I need help with is, when I tapped the actor, it bounced left, but if I held my finger down it carried on bouncing upwards, which is cheating, so how would I make it that it doesn't bounce if you hold your finger down? It should only bounce when you tap on it. Hope I'm making sense here!
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    You're making perfect sense and I understand completely now what you want to achieve, now you've explained fully. It's difficult to help though without seeing your bouncing Rules. If you've the time to post all the rules you have in your actor here, I'll be able to see what "angle of attack" you're using. Or as an alternative, I'd be willing to look at your file if you want to send it to me.

    Back to the holding finger down aspect: without seeing what Physics you're using I'm not 100% certain that a boolean attribute acting as a switch would work, but it might.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • TheodiTheodi Member Posts: 96
    Hi again,

    1st rule

    Touch Animation. When pressed actor animates, and plays a sound.

    Then a collide with a wall to the right.

    Then another collide with a wall to the left.

    2nd rule

    When game.pungi1 is true

    after timer of 3 seconds, play sound, looped.
    Control Camera

    Rule 3

    Attribute game.tap is true
    accelerate direction 270 relative to actor, 350 speed.

    Rule 4
    (this doesn't work properly, it is supposed to be a score, depending on the actors height. I need this working to but can't get it to work)

    attribute self.position.x is less than game.heightscore
    change attribute game.heightscore to self.position.x

    Thats it. Hope you can help!
  • TheodiTheodi Member Posts: 96
    The rule I was using before for bouncing left or right was dependant on which side of the actor you tapped. So if you tapped the actor on the left hand side it bounces right, and vice versa. It was something like, If tapped self.position.x is less than self.position.x then change velocity etc.
  • TheodiTheodi Member Posts: 96
    Anyone know a fix for this?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    http://gamesalad.com/game/2810

    using the math in that demo when the touch is release and magnitude is close enough to be a touch, would probably get you going
  • TheodiTheodi Member Posts: 96
    How do I download the file?
  • TheodiTheodi Member Posts: 96
    I fixed it! Using the rules I originally used, tweaked them a bit now its working well.

    I still need to add a rule that makes it, so the player cant hold their finger down to keep the actor bouncing up, but they have to actually tap, and only if the actor is going down, otherwise the game is too easy, to just keep tapping. Anyone got idea about this?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi, sorry I didn't get round to helping out in the end but glad you got it sorted... for your latest prob., maybe tried When touch is released rather than when pressed?

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • TheodiTheodi Member Posts: 96
    Yes that works. I prefer pressed though it makes the gameplay better, but it solves the problem so thats fine!

    Gyro do you know a good way to record a score? Based on the height of the actor. So it goes up everytime the actor goes a bit more upwards. A bit like papi jump?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    I don't know papi jump but still, off the top of my head, something along the lines of the actor's Y coordinate divided by however many divisions you want.

    So, put actor's max. y into an integer attribute, let's call it JumpHeight; say 10 divisions, so JumpHeight/10; result into a real attribute called JumpRes. Put floor(JumpRes) into another attr. called Jumpfinal.

    Then when JumpFinal > 20 and < 40
    ---your score stuff
    otherwise
    when JumpFinal > 39 and < 60
    ---your score stuff
    otherwise ---etc; i.e nesting the otherwise's.

    Hope that gives you some sort of start.

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • TheodiTheodi Member Posts: 96
    Ill try that out, thanks Gyro! Might ask you for some further help as Im still new at GS!
  • TheodiTheodi Member Posts: 96
    On release rule is not working well when testing on the ipod touch. So is there a way I can use on pressed, without having the trouble I had earliar with that, which was, players could just hold down there finger and it would carry on going up, instead of them taping to make it jump up. Maybe a switch? Any ideas?

    gyro I couldn't get the above to work for the score, Im not that experienced at GS yet I couldn't get it working!
Sign In or Register to comment.