About Monkey 2 › Forums › Monkey 2 Development › Bug or not ? 2 windows only one draws something, and can't use variables
Tagged: multiple windows
This topic contains 3 replies, has 2 voices, and was last updated by
gcmartijn 2 years, 7 months ago.
-
AuthorPosts
-
August 31, 2016 at 12:07 pm #3569
My first attempt to use two windows fails because the ‘second’ / last loaded window (editor) is not drawing anything.
My idea is to separate the game and the editor, and the game is actual ‘playing’, and with the ‘live’ editor window I can change things.
After the first problem I get another one the interaction between the two windows.
Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243444546Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class GameWindow Extends WindowField accessibleField:String = "cool"Method New(title:String,width:Int,height:Int)Super.New( title,width,height,WindowFlags.Center)SwapInterval=1EndMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()canvas.DrawText( "Game",Width/2,Height/2,.5,.5 )EndEndClass EditorWindow Extends WindowMethod New(title:String,width:Int,height:Int,gameWindow:Window)Super.New( title,width,height,WindowFlags.Center)SwapInterval=1' Print gameWindow.accessibleField ' don't work eitherEndMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()' Not showingcanvas.DrawText( "Editor",Width/2,Height/2,.5,.5 )EndEndFunction Main()New AppInstanceLocal gameWindow:Window = New GameWindow("Game",600,800)New EditorWindow("Editor",200,400,gameWindow)App.Run()EndAugust 31, 2016 at 7:39 pm #3582Multilpe windows has NOT been thoroughly tested yet is likely to cause problems!
Also, you can only use multiple windows on desktop targets, not mobile/web.
September 1, 2016 at 9:21 am #3589I understand, its a desktop editor to create games while running them.
Don’t know if you are going to do a rough check in the near future so I wait.
September 10, 2016 at 6:11 pm #3853I know you may don’t have time for this but maybe you can see the problem what I discovered here.
Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071Namespace myapp#Import "<std>"#Import "<mojo>"#import "<mojox>"Using std..Using mojo..Using mojox..Global game:GameClass GameField accessibleField:String = "game text"Method render(canvas:Canvas)canvas.DrawText(accessibleField,50,50,.5,.5 )EndEndClass GameWindow Extends WindowMethod New(title:String,width:Int,height:Int)Super.New( title,width,height,WindowFlags.Center)SwapInterval=1EndMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()game.render(canvas)EndEndClass EditorWindow Extends WindowMethod New(title:String,width:Int,height:Int)Super.New( title,width,height)SwapInterval=1Local label:=New Label( "Idle" )label.Gravity=New Vec2f( .5,0 )Local button:=New Button( "Click ME!" )button.Clicked=Lambda()Global n:=0n+=1label.Text="Clicked #"+n' game.accessibleField="Clicked #"+nEnd'Local dockingView:=New DockingViewdockingView.AddView( label,"top" )dockingView.ContentView=buttonContentView=dockingViewEndEndFunction Main()New AppInstancegame = New Game()New GameWindow("Game",600,800)New EditorWindow("Editor",200,400)App.Run()EndWhen you run this code above, then the editor window is on top, and is black.
You see in the GameWindow the a text in the top.Magic 1
When you press +/- 10px below the middle inside the Editor window (there is the button located), then everything is visible in the Editor window !Magic 2
But the GameWindow din’t update, because now some new magic will happen.
Uncomment the lineMonkey1' game.accessibleField="Clicked #"+nWhen you do the same as Magic 1 above, then nothing will be visible inside the Editor window.
But the GameWindow will will update the text like I want !Magic 3
Comment the line above again, and now the bonus magic.
Change the line in the top to thisMonkey1Field accessibleField:String = "game window text"With this the string is larger, and what do you think: magic 1 is now not working, only by making the text a longer.
Then I thought, what do people say about sdl two windows, so I can use that.
But using some examples in combination with the bananas/sdl2test gives the same output.
http://stackoverflow.com/questions/21691450/how-to-create-a-subwindow-using-sdl
http://stackoverflow.com/questions/22227811/sdl2-and-opengl-functions-with-two-windowsI don’t know if MX2 is doing something wrong or SDL.
Now I’m thinking about this, maybe I switch back to a in game editor window that you can move around like the /bananas/calculatorIt has some pros and cons to do a editor in game or in a external editor window.
-
AuthorPosts
You must be logged in to reply to this topic.