Forum Replies Created
-
AuthorPosts
-
July 9, 2016 at 11:30 am in reply to: How can I control the framerate / How does the loop loops? #1953
@abakobo
No you don’t need to separate out your update (you can certainly as the above example shows). Put everything into the OnRender as follows:Monkey123456789101112Method OnRender(canvas:Canvas) Override'UpdateMyObjects.Update()'other things you wish to update'RenderApp.RequestRender()MyObjects.Render(canvas)'other things you wish to render'ie. scoreEndThis way the system handles everything – most of the available samples follow this example. You can create the OnUpdate timer if you want to update more regularly or at a specific rate.
That did catch me out initially trying to work through what was what.
Ok – thanks for taking a look Mark!
Put a DebugStop() before the area you wish to debug and once it’s hit the debugger becomes active in Ted2. As before best to run in a window.
I’ve raised an issue for this:
https://github.com/blitz-research/monkey2/issues/24@pakz
Thanks for checking! Hopefully Mark can determine the problem here.Also haven’t seen any slow downs like that myself.
I believe the ? operator will be added soon which will verify if an object is null before using it:
http://monkey2.monkey-x.com/monkey2-roadmap/so you could do entity?.Update() in you example.
Nice!
That may have been fixed:
https://github.com/blitz-research/monkey2/commit/a9ad08504e5a25b0862bafb4005b8475747c864c
[/crayon]Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677[crayon-5cba8f34f16c5376378986 inline="true" ]'System#Import "<std>"#Import "<mojo>"Using mojo..Using std..' GlobalsGlobal window:MainWindowFunction Main()New AppInstance()window = New MainWindow("Main Window",1024,768,WindowFlags.Resizable) 'Fullscreen/ResizableApp.Run()EndClass MainWindow Extends WindowField IsPaused:BoolField IsSuspended:BoolField ShowFPS:Bool=TrueMethod New(title:String, width:Int, height:Int, flags:WindowFlags)' Setup displaySuper.New(title, width, height, flags)'Virtual ResolutionLayout = "letterbox"MinSize=New Vec2i(640,480)MaxSize=New Vec2i(width,height)ClearColor = Color.BlackMouse.PointerVisible=FalseEnd MethodMethod OnRender(canvas:Canvas) Override'RenderApp.RequestRender()'MessageLocal message:String="Hello from Monkey2!"canvas.Color=Color.Whitecanvas.DrawText(message,Width/2-Style.DefaultFont.TextWidth(message)/2,Height/2)'SystemIf (ShowFPS) canvas.DrawText("FPS-" + App.FPS,0,0)End MethodMethod OnKeyEvent( event:KeyEvent ) OverrideSelect event.TypeCase EventType.KeyDownSelect event.KeyCase Key.F12Fullscreen = Not FullscreenCase Key.EscapeApp.Terminate()Case Key.FShowFPS=Not ShowFPSEndEndEndMethod OnWindowEvent(event:WindowEvent) OverrideSelect event.TypeCase EventType.WindowMovedCase EventType.WindowResizedApp.RequestRender()Case EventType.WindowGainedFocusSelf.IsSuspended = FalseCase EventType.WindowLostFocusSelf.IsSuspended = TrueDefaultSuper.OnWindowEvent(event)EndEndEnd ClassNice – all worked here.
Thanks therevills!
Add *.buildv* to your .gitignore file! Easy!
Nearly missed it – will check it out Wiebo!
the Theme.monkey2 file of Ted2 contains the loader for the config file. Do you have to load fonts via the #Import feature or can they be loaded directly via the load command? Haven’t tried that as yet.
Yeah – the editor definitely needs a mono-spaced font. I grabbed Consolas (consola.ttf) and renamed it to what the editor is looking for (RobotoMono-Regular.ttf) and it worked fine for now.
Great – thanks Mark!
-
AuthorPosts