How can I control the framerate / How does the loop loops?

About Monkey 2 Forums Monkey 2 Programming Help How can I control the framerate / How does the loop loops?

This topic contains 5 replies, has 4 voices, and was last updated by  Matthew Smith 2 years, 10 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1886

    abakobo
    Participant

    The FPS property is not assignable…

    how can I control the framerate. Is it just waiting for VerticalBlank and dependent to my screen refresh rate?

    I don’t really get the whole event loop of the AppInstannce/Window classes. Is there a link with a full explanation (more than the summary of the docs)?
    I remember I read some things about fixed framerate and other things like that. I’ve also seen examples with the OnUpdate method in MX2 but can’t find it in the docs. What has really changed and how?
    Is even there some eventloop if ‘App.RequestRender’ is not called?

    #1917

    Pakz
    Participant

    <pre class=”lang:monkey decode:true ” title=”Framerate”>#Import “<std>”
    #Import “<mojo>”

    Using std..
    Using mojo..

    Global instance:AppInstance

    Class MyWindow Extends Window

    Field timer:Timer

    Method New()
    timer = New Timer(10,OnUpdate)
    End Method

    Method OnUpdate()
    If Keyboard.KeyReleased(Key.Escape) Then instance.Terminate()
    App.RequestRender()
    End Method

    Method OnRender( canvas:Canvas ) Override
    canvas.DrawText(“FPS:”+App.FPS,0,0)
    End Method

    End Class

    Function Main()
    instance = New AppInstance

    New MyWindow

    App.Run()

    End Function
    This I used to change the framerate. Using a timer.

    #1919

    Pakz
    Participant

    The code insertion seems not to work? No idea what is happening.

    #1931

    Mark Sibly
    Keymaster

    Sorry about that – more wordpress weirdness, should be fixed now.

    #1952

    abakobo
    Participant

    Ok so OnUpdate (not documented yet) is a must in some situations…? May be I should wait for more complete docs before trying to understand the whole appInstance/window process.

    #1953

    Matthew Smith
    Participant

    @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:

    This 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.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.