How to read the offset of a scene via Lua

  • #1, von htw8849Montag, 21. März 2016, 17:19 Uhr vor 9 Jahren
    Hi,

    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 ?

    Example:
    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

    Neuling

    41 Posts


  • #2, von afrlmeMontag, 21. März 2016, 18:06 Uhr vor 9 Jahren
    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}
    

    Foren Imperator

    7285 Posts

  • #3, von htw8849Montag, 21. März 2016, 18:18 Uhr vor 9 Jahren
    Ah, that's it - thank you very much smile

    Neuling

    41 Posts