getting current scene dimensions?

  • #1, by rhavin grobertSunday, 05. November 2017, 21:35 7 years ago
    Tried the following:

      local scene = game:getLink(VGameCurrentScene)
    
      print ("--- start ---")
    
      for v,t in pairs(scene.SceneScrollableArea) do
    
        print (v,t)
    
      end
    
      print ("--- end ---") 


    message.log is

    21:31:24.814:--- start ---
    
    21:31:24.814:y	0
    
    21:31:24.814:x	0
    
    21:31:24.814:height	0
    
    21:31:24.814:width	0
    
    21:31:24.814:--- end ---

    of course, the scene actually *is* a bit bigger wink

    So, how do i get the dimensions of the current scene?

    Newbie

    47 Posts


  • #2, by sebastianSunday, 05. November 2017, 22:15 7 years ago
    You need the size of the background sprite. The scrollable area is "0"in width/height if it has no limits set (default).


    There is a function getSize() to return a size of a sprite.

    Use this:
    game.CurrentScene.Sprite:getSize().x
    game.CurrentScene.Sprite:getSize().y

    Thread Captain

    2346 Posts

  • #3, by rhavin grobertSunday, 05. November 2017, 22:18 7 years ago
    Ok, found something that I can use as a workaround by pure chance

    http://www.visionaire-studio.com/luadocs/#commands

    local scene = game:getLink(VGameCurrentScene)
    print(scene.SceneSprite:getSize().x)
    


    Still, I actually want to know the dimensions of the (scrollable) scene, regardless of the sprite that might be smaller or bigger.

    From an OO point of view, getting the size of the scene has to be a method of the scene!

    Newbie

    47 Posts

  • #4, by ke4Sunday, 05. November 2017, 22:19 7 years ago
    Edit: I see Sebastian already answered razz

    SceneScrollableArea sets the limit how far you can scroll. You can limit that to 100px for example.

    ScrollPosition gives you how much is currently scrolled.

    WindowResolution will give you the game resolution.

    This could give you the scene size i suppose.

    game.CurrentScene.Sprite:getSize()

    Key Killer

    810 Posts

  • #5, by sebastianSunday, 05. November 2017, 22:27 7 years ago
    From an OO point of view, getting the size of the scene has to be a method of the scene!
    The size of the scene is determined by the sprite you use there. And the sprite field for a scene is a link to the used image (and some other informations). 

    If you need the size of the actual scrollable area, you may need to create a function which checks if the scrollable area width/height is 0. If not, use that . If its 0, use the sprite size.

    Thread Captain

    2346 Posts