Saving an Angle

Hi all,

In my game I have 4 handles in 4 separate scenes and when you touch them they rotate to 4 90degree angles.

I need to be able to save the angle that the handles are at so when you return to the scene it is in the position you left it in.

I've tried changing the handles' 'self' rotation to a 'game' rotation attribute in order to save it but it doesn't seem to work.

Any ideas appreciated.

It’s not a bug – it’s an undocumented feature

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited October 2013

    Hi @Fal01 First to say, your right to use game attributes as they are all in separate scenes ("safer", I'm thinking...)

    Next to say, you will need 4 attributes, one for each of the positions you want saved.

    You could make these as Angle attributes:

    game.Handle01Angle, game.Handle02Angle, game.Handle03Angle, game.Handle04Angle --so these are used like:

    Constrain Attribute Handle01Angle to self.Rotation

    When the angles change, use a Save Attribute behaviours. And providing you use Load Attrbute behaviours to continue a game when restarting the app, they'll be "remembered" then as well.

    Hope that helps.

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

  • Fal01Fal01 Member Posts: 460
    Thanks a lot @gyroscope,
    Yeah, that's basically what I've got set up except I had change attribute instead of constrain. Doh!
    It's working now :)

    It’s not a bug – it’s an undocumented feature

  • Fal01Fal01 Member Posts: 460
    @gyroscope,

    I just noticed that the angle is saved all the way around the game(point and click) until I get back to the scene where I've moved the handle and then it resets itself back to zero.

    Is there a fix for this?

    It’s not a bug – it’s an undocumented feature

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited October 2013

    Hi, yes, try this: In each of the Handle actors' Rules, add at the beginning:

    Change Attribute self.Handle01.Rotation to game.Handle01Angle

    ---and so on for the other three, changing the numbers accordingly, of course

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

  • Fal01Fal01 Member Posts: 460
    Cheers @gyroscope,

    Last question I promise :D

    I have an index attribute which counts when each handle is at the correct angle, so when handle count=4 Handles correct=true.

    The problem is that every time I return to the scene it counts up by another 1
    how do I stop it counting past 1?

    It’s not a bug – it’s an undocumented feature

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited October 2013

    Last question I promise :D
    It's OK, fire away with as many questions as you like! :-) (As long as they're not all at once... ;-) )

    So try something like: make 4 booleans; then in each of your handles actors add (changing numbers accordingly):

    Rule: When Handle01Correct is false and game.Handle01Angle = 180 ---- or 90, 270 or 0 depending----
    Change Attribute Handle01Correct to true
    Change Attribute HandleCount to HandleCount+1

    ----

    ---and somewhere you have your Rule:

    Rule: When HandleCount = 4
    Change Attribute HandlesCorrect to true

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

  • Fal01Fal01 Member Posts: 460
    Thanks for all your help @gyroscope, you're a star! :-bd

    It’s not a bug – it’s an undocumented feature

Sign In or Register to comment.