How to read the offset of a scene via Lua

  • #1, by htw8849Monday, 21. March 2016, 17:19 4 years ago

    ok this might be a rather stupid question, but is there a simple way in LUA to read the display offset of a scene compared to the size of the background ?

    I have a scene background image of 4900x720 pixel and I use a 1280x720 resolution for my game, so obviously the scene is scrolling left and right while walking through it.

    So for example if I walked like 1000 pixels to the right, how can I read out via LUA that the scene is currently displaying the background between 1000 and 2280 ?

    Unfortunately I cannot find anything about the scene position in the data structure help at the Visionaire Studio wiki.

    So maybe some of guys have a Idea how to solve that smile


    41 Posts

  • #2, by afrlmeMonday, 21. March 2016, 18:06 4 years ago
    What you are actually looking for is the scroll position...
    game.ScrollPosition.x -- returns the x coordinate position
    game.ScrollPosition.y -- returns the y coordinate position

    This is the current position (x, y coordinate) of the scene in the viewport.

    P.S: you can actually use the same code above to manually set the scroll position too. wink
    game.ScrollPosition.x = 100 -- or whatever value you want
    -- you can also update both x & y in the same line, like so...
    game.ScrollPosition = {x = 100, y = 50}
    -- or you can even update one & keep the other at the same value...
    game.ScrollPosition = {x = 100, y = game.ScrollPosition.y}


    6842 Posts

  • #3, by htw8849Monday, 21. March 2016, 18:18 4 years ago
    Ah, that's it - thank you very much smile


    41 Posts

Write post