Gravity Flip Woes

rexus11rexus11 Member Posts: 11
edited November -1 in Working with GS (Mac)
Hey guys, im quite new to GS and im currently making a game with a gravity flip option (or atleast trying).

Here is the method i have at the moment but i seem to get contrasting behaviours and i would very much appreciate some advice.

i create an attribute called gravflip (integer set to 0)

on my iphone button, i have the rule.

if touch is released + attribute 'gravflip = 1' - change attribute gravflip to 0
in the otherwise i have the rule:
Otherwise
if touch is released + attribute 'gravflip = 0' - change attribute gravflip to 1

afaik. that should set the controls right.

on the player side of things. i have an accelerate behaviour going down at 1500 and have it set to otherwise:
if gravflip = 1 - accelerate up - 1500

could someone tell me please what im doing wrong?

ive spent like 3 hours on this and i have my suspicions that the game attribute is constantly switching between 0-1 and this is giving me some sort of slow accelerating hover effect.

hase anyone else encountered this, and if so, how can i fix it?

Thanks,

Craig

PS: LOVE THIS COMMUNITY!

Comments

  • svnsvn Member Posts: 445
    Change "when touch is Released" to "Pressed". The game thinks that since you're not touching the iPhone, touch has been Released. So it keeps on changing.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    It's because the Acceleration behavior can't be interrupted very successfully; it needs to decellerate before it can change direction. One way to do this is, when changing direction, just before each Acceleration behavior, you need another with the Speed set to 0. Even then, the direction won't change straight away; you have to wait for it to stop before it changes direction.

    Maybe experiment with using the Change Velocity behaviour instead? This should be more instant, as you want.

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

  • rexus11rexus11 Member Posts: 11
    Button pressed gives an odd result, gravity only changes whilst the button is pressed. Will test velocity and get back to you guys!
  • rexus11rexus11 Member Posts: 11
    okay i tried change velocity and the character seems to only move upwards. and not even continuously. it sorta starts moving then gives up.

    this is driving me insane, because it 'should' work with either method :(
  • rexus11rexus11 Member Posts: 11
    im also not 100% how to go about adding two 'accelerate' behaviours as the way i tried only had the player effected by the accelerate = 0 value
  • rexus11rexus11 Member Posts: 11
    i think ive came to the conclusion that its a problem with my buttons.

    because i now have a longer string of

    button attrib=0
    on press change to 1 (and vice versa)

    attrib = 1
    change actor attrib = 1 (and vice versa)

    actor attrib = 1 (accelerate upwards)

    the reaosn i came to this conclusion is that now i have the flip 'half' working. once the button is pressed once, the flip works perfectly. however, after a single press, the values of the attributes no longer seem to change.

    im using integers for the attributes. is there anything that could be a problem there?
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Try this instead.

    2 Game Attributes.

    gravity - real attribute
    gravflip - integer attribute

    Now For you button

    Touch is pressed
    --Change game.gravflip to (game.gravflip+1)%2

    second rule

    When game.gravflip is 0
    Change game.gravity to 270
    otherwise
    Change game.gravity to 90

    ---------------------------
    Now in all of your actors affected by gravity remove all of your accelerate rules and just place a single accelerate behavior at the top.

    And in the direction box use the expression editor and and select game.gravity

    This will flip the gravity back and forth each time the flip button is pressed
  • RHRH Member Posts: 1,079
    For changing the gravity, if it is just changing to go up or down at the same rate just make a rule that:

    when actor receives event touch is pressed change game.gravity to -game.gravity

    on the actors that you want affect add an accelerate behaviour with direction: 90 relative to scene and acceleration game.gravity

    This is probably the most efficient way to do it
  • rexus11rexus11 Member Posts: 11
    i must be having another issue with my file because it just keeps my player suspended in air.

    is there any chance someone could take a look at it and see where im going wrong exactly?

    Direct Link:
    http://www.megaupload.com/?d=14SGNTUD
  • RHRH Member Posts: 1,079
    There's definitely a bug in your project somewhere. Just had a quick look but I'm afraid I don't have the time to find it at the moment.

    Once you get it sorted the method I posted will do the trick.
  • UtopianGamesUtopianGames Member Posts: 5,692
    Our free template over at DBA has gravity flip, its a runner game but you might find the code helpful.



    Darren.

    http://www.deepblueapps.com/Deep_Blue_Ideas_Ltd./Free_Stuff.html

    image
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    I just made you a simple little demo Search, simple gravity flip under new in GameSalad. It will be downloadable.

    http://gamesalad.com/g/35290

    Hope That helps.
  • rexus11rexus11 Member Posts: 11
    if anyone else could help find this bug, i would be deeply appreciative.

    its my first project, so im afraid, i dont quite know exactly what id be looking for
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Remove all accelerate rules and behavior. before trying to add anything we have told you. You most likely have a bunch of stuff conflicting with the rules. If you want me to take a look you can head over to the marketplace and check out my project help sticky for details but I really think you can sort this out on your own if you just give it a chance and follow what we have told you.
  • rexus11rexus11 Member Posts: 11
    @tenrdrmer

    And the rest of you guys really.

    Thanks alot for all of the help.

    something within the button animation was stupidly conflicting with the gravity flip attribute, so i deleted the button and inserted a fresh actor and then copied the code example and it works. really sorry to have been a pain!
Sign In or Register to comment.