License from €75 Log in
DE EN FR ES IT CZ

getting current scene dimensions?

This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials

  1. · 9 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?
  2. Working on a game?

    The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license.

    See licenses Try it for free
  3. · 9 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
  4. · 9 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!

  5. · 9 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()
  6. · 9 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.

This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.

New thread

Really delete this post?