June 12, 2018 at 8:15 pm #14821
I’ve been trying to figure this out, but there doesn’t seem to be an obvious way to do it.
I also tried recreating the window with a new size, but that leaves me with two windows because I don’t know how to destroy the first one.June 12, 2018 at 11:52 pm #14823
The easiest way is to override the window size in the window constructor.
Have a look at the mojo template project – replace the 640,480 with your desired size:Monkey123456789101112131415161718192021222324252627282930313233Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowMethod New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )EndMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()canvas.DrawText( "Hello World!",Width/2,Height/2,.5,.5 )EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndJune 13, 2018 at 12:02 am #14824
Ah, sorry, I should’ve been more clear… :\
I meant it as in changing the window size during runtime. If I could do that I might have different resolution options that the player can choose from.June 13, 2018 at 12:40 am #14828
The View.Frame property can be used to ‘layout’ views – try adding this to your Window class:Monkey1234Method Resize( width:Int,height:Int )Frame=New Recti( 0,0,width,height ).Centered( New Recti( 0,0,App.DesktopSize ) )End
I’m reluctant to add this to the Window class as a ‘core’ method as it duplicates functionality that’s already there (ie: Frame). However, perhaps it would make sense to add some stuff like via built-in extension methods? This approach worked out well with Entity class IMO.
And of course if your doing fullscreen there is also BeginFullscreen/EndFullscreen…June 13, 2018 at 2:23 am #14830
Hey that works! 🙂
Well, I think maybe at least there could be a sample program that uses it. Maybe Pakz could add it to his collection of examples. Unless he already has it and I overlooked it…June 13, 2018 at 6:23 am #14832
Or, you could add this to mojo/app/windows:Monkey123456789[crayon-5b73d24b098ed519113377 inline="true" ] method WindowResize( x:int, y:int, width:int, height:int)SDL_SetWindowPosition( _sdlWindow, x, y )SDL_SetWindowSize( _sdlWindow, width, height )_frame = GetFrame()Frame = _frame_weirdHack = trueEndJune 14, 2018 at 7:33 am #14840
add some stuff like via built-in extension methods?
Yes a simpler official resize method would be nice…June 14, 2018 at 5:27 pm #14843
> Yes a simpler official resize method would be nice…
Ok, will do.June 15, 2018 at 12:04 pm #14848
I have a request, would it possible to also create a flag for the titlebar on Android so it could be toggled at runtime?
You must be logged in to reply to this topic.