Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Window resize event — Gideros Forum

Window resize event

Unknown Member
edited May 2016 in General questions
Is there such an event? I would like to make a game that scales when the window is resized.

Comments

  • keszeghkeszegh Member
    there is Event.APPLICATION_RESIZE, add a listener to it and then you can manually update game scales when the window is resized.

    Likes: oleg

    +1 -1 (+1 / -0 )Share on Facebook
  • keszeghkeszegh Member
    in any case i also could not find it in the reference or guide, in general (a note for @john26, @ar2rsawseen) it's hard to find information about events in the reference. some of them is explained here but not all:
    http://docs.giderosmobile.com/events.htm
    but i think everything should be in the reference page (and it should be searchable in the longterm)
  • piepie Member
    There is also gideros Scale Mode - Stretch, but it's not the best option because you risk to lose the aspect ratio
    http://docs.giderosmobile.com/automatic_screen_scaling.html

    Likes: keszegh

    +1 -1 (+1 / -0 )Share on Facebook
  • john26john26 Maintainer
    @kezegh, you are right this event needs to be added to the docs. I was also thinking of adding a new section listing all the graphics objects (Sprites) and one on the sound system.

    @chimmihc, probably you are already aware but in the simplest case there is no need for you to do anything when the user resizes the window. The app will simply resize within the window according to the scale mode you use. Letterbox scaling is probably the best as stretch can product highly distorted results if showing a portrait game in a landscape window for example (eg if the user maximises the window to fill a typical landscape screen).

    You can test this within the Gideros Desktop Player by setting autoscale from the hardware menu. Then, just drag the sides of the window (or maximise) to see the effect.

    However, note that if you export using Windows Desktop or Mac Desktop and you have set "window size" (in the project properties dialog, see attached) to non-zero values, then the window will be fixed size and the user cannot resize it.

    If you export with "window size" to (0,0), the window will initially be the logical dimensions size and the user can resize.

    So for simple resizing you don't need to do much, but if you want to change the layout of your app you obviously need to respond to events.
    projectproperties.png
    422 x 485 - 30K
  • olegoleg Member
    edited July 2019
    I'm trying to get a new window size-but the size is not updated
    how to get the window size?
    	minX,minY,maxX,maxY=application:getLogicalBounds()
    	stage:addEventListener(Event.APPLICATION_RESIZE,function()
    		print("--- RESIZE ---",(minX-maxX)*-1)
     
    	end)
    the size changes when I restart the game
    How do I know about resizing without restarting the game?

    Likes: MoKaLux

    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
    +1 -1 (+1 / -0 )Share on Facebook
  • olegoleg Member
    edited July 2019
    application:getLogicalBounds - does not work with APPLICATION_RESIZE


    the old method works:
    does not work either
    stage:addEventListener(Event.APPLICATION_RESIZE,function()
     
    contentWidth = application:getContentWidth()
    contentHeight = application:getContentHeight()
    logicalTranslateX = application:getLogicalTranslateX()
    logicalTranslateY = application:getLogicalTranslateY()
    logicalScaleX = application:getLogicalScaleX()
    logicalScaleY = application:getLogicalScaleY()
     
    logicalScreenLeft = -logicalTranslateX / logicalScaleX
    logicalScreenTop = -logicalTranslateY / logicalScaleY
    logicalScreenWidth = contentWidth + logicalTranslateX / logicalScaleX * 2
    logicalScreenHeight = contentHeight + logicalTranslateY / logicalScaleY * 2
    print("--- RESIZE ---",logicalScreenWidth ,logicalScreenHeight )
     
    	end)

    Likes: MoKaLux

    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    oleg said:

    	minX,minY,maxX,maxY=application:getLogicalBounds()
    	stage:addEventListener(Event.APPLICATION_RESIZE,function()
    		print("--- RESIZE ---",(minX-maxX)*-1)
     
    	end)
    This works for me... after moving the getLogicalBounds() call inside the event listener of course!

    Likes: oleg, keszegh, MoKaLux

    +1 -1 (+3 / -0 )Share on Facebook
  • olegoleg Member
    edited July 2019
    I realized it was necessary to do so ..
    	stage:addEventListener(Event.APPLICATION_RESIZE,function()
    		minX,minY,maxX,maxY=application:getLogicalBounds()
    		print("--- RESIZE ---",(minX-maxX)*-1)
     
    	end)

    Likes: MoKaLux

    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.