Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Saving x and y positions

edited February 2014 in Questions Posts: 17

I am using a joystick in my game, and I need it to save the players location if you pause or go into the inventory or whatever, I am using this:

sprite(guy,object.x,object.y,460,300)

How could I do this? I have never done anything related to saving before and any help would be appreciated.

Comments

  • Posts: 2,820

    Are you talking about saving the data after you close the app, or just temporarily? If you want to save it after the app is closed, use saveLocalData. If you save it just while you go to a different state, set it as a global variable, then read it again.
    Welcome to the forums!

  • Ok, but what would I save the variables value as? I tried

    SaveLocalData("object", object.x)
    SaveLocalData("object", object.y)

    But that doesn't work, I guess I'm naming something wrong but what would that be?

  • Posts: 2,820

    Use saveLocalData with a lowercase "s". When you want to read it, use readLocalData(key). BTW, if you want to notify me when you're talking to me, use @Zoyt, in case you didn't know.
    Thanks!

  • Posts: 23

    saveLocalData('objectX', object.x)
    saveLocalData('objectY', object.y)

    Local savedX = readLocalData('objectX')
    Local savedY = readLocalData('objectY')

Sign In or Register to comment.