May 7, 2018 at 12:33 am #14585
Good evening everyone. I’m taking a beating to use the Mojox library. I’m developing a library for retro style RPG games (like The Legend of Zelda [NES]) and would like to create a stage editor for it …
Oh, that’s the problem. I’m completely lost here. In BlitzMax I did not have many complications, but in Monkey 2 I still did not understand how the GUI works.
Does anyone have an example of how to join GUI interface with the rendering of the game itself?May 7, 2018 at 1:18 am #14586
The main idea is to write a ‘GameView’ style class that implements your game rendering, and then to add that to your app’s view hierarchy, eg:Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849#Import "<std>"#Import "<mojo>"#Import "<mojox>"Using std..Using mojo..using mojox..Class GameView Extends ViewMethod OnRender( canvas:Canvas ) Overridecanvas.DrawText( "Game Rendering goes here!",Width/2,Height/2,.5,.5 )EndEndClass GameWindow Extends WindowField _gameView:GameViewField _textView:TextViewField _dockingView:DockingViewMethod New()_gameView=New GameView_textView=New TextView_dockingView=New DockingView_dockingView.ContentView=_gameView_dockingView.AddView( _textView,"right",320,True )ContentView=_dockingViewEndEndFunction Main()New AppInstanceNew GameWindowApp.Run()End
This sets up a docking view that contains your game view as its ‘main’ view and adds a resizable TextView on the right.
Have a look in modules/mojox/tests for some mojox examples.May 7, 2018 at 1:38 am #14587
Thank you Mark. (Now I’ve opened my vision a little more, but it’s still confusing …).
Taking advantage of the hook, I also miss out on how the coordinates of the GUI components on the screen work.
In BlitzMax, he used the x, y coordinates. I still try to understand how the organization works in Monkey 2.
Could you give me a brief explanation of how it works?
Note: I have already looked at all the examples and still I still do not understand very well.May 7, 2018 at 9:08 pm #14590
The general idea is for mojox to do all the layout stuff for you, so you don’t have to worry about positions/sizes etc so much. This allows guis to work on a wide range of resolutions and devices and to respond very dynamically when windows are resized etc.
You generally create a hierarchy of views using DockingViews, ToolBars, ListViews, TreeViews, GridViews etc and mojox does the positioning and sizing for you when it needs to update the GUI layout.May 8, 2018 at 12:21 am #14592
Hey Mark … Now I understand how it works. I spent the day looking at all the forum posts related to Mojox, and it opened my mind more. I’m still confused about some things, but I understand their operation much more.
I’ll keep doing my tests here. And once again, thank you for your help.
You must be logged in to reply to this topic.