Monkey 2 App Template

About Monkey 2 Forums Monkey 2 Programming Help Monkey 2 App Template

This topic contains 13 replies, has 3 voices, and was last updated by  codifies 2 years, 3 months ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #6487

    APC
    Participant

    Hello Monkey Team,

    I put together a Monkey 2 App template for GUI that includes the OnRender, OnUpdate and the OnActivate and OnDeactivated ( same as MX1 OnSuspend and OnResume), I am assuming that OnLoad happens in the App initialization Method (New). On the second code I implemented the “isSuspended” to minimized the app activity in the background, so I save the App.FPS in this mode and display it when the Window app is Maximized. I need your input to finalize this template and share it with you.

    Now for Mobile Devices we need to reduce app activity on the background to save battery power, so a added the following to the code and I want to know if what I did reduces power consumption. Minimize the App window on PC or press the Home button to put it in the background. In MX1 I setup the update rate to 5 (SetUpdateRate(5)) in suspended and back to 60 (SetUpdateRate(60)) on resume, I don’t know if this is the case with MX2.

    #6488

    codifies
    Participant

    check with a cpu load meter both on all platforms you can, but you might need to yield to the OS (sleep) after onDeactivated.

    I’d do some canvas.scale first thing onRender, so you can preserve either a fixed resolution (that gets scaled) or ideally a fixed resolution scalled to a fixed aspect ratio…

    also in keywords – can you mix up the case a bit like UsInG just for pedants… >:)

    #6489

    APC
    Participant

    I tested on iOS 10.2 on iPhone 6 and when it goes to OnDeactivate the app sleeps, the behavior is different on PC running Windows 10 and the same on my MacBook Pro running OSX Sierra, they run on the back ground. I will run on my Android device.

    #6494

    impixi
    Participant

    You could try something like this:?

    [/crayon]
    #6498

    APC
    Participant

    impixi,

     

    Thank you this looks much cleaner, one interesting thing is the FPS in my Original template runs at 60 frames per second , on yours the frame rate is much higher, on Windows and OSX.

    This works great with mobile, I tested on iOS so far .

    #6505

    APC
    Participant

    Here is the updated Monkey 2 App Template.

    #6513

    impixi
    Participant

    one interesting thing is the FPS in my Original template runs at 60 frames per second , on yours the frame rate is much higher, on Windows and OSX.

    SwapInterval = 0 disables vsync, I believe, so that’s the frame rate difference.

    #6528

    codifies
    Participant

    bare in mind vsync can be overriden by user settings on Linux, ~/.drirc on Intel GPU and on Nvidia there is a GUI that allows you to override frame sync.

    Looking at the way most games work, including unity seem to just ignore user settings and assume frame sync is enabled meaning they run at silly speed! There are some games that seem to work correctly however regardless of user sync setting.

    can I suggest that you make some of the methods abstract and those that do need code like OnRender make them call another method that is abstract. My idea is here that the end user would have one object to create and just simply override methods in the framework rather than hacking on the framework itself…

    #6532

    APC
    Participant

    codifies, it is a good suggestion. Can you send me a sample code of what you proposed?

    #6535

    codifies
    Participant

    you’d like me to write it for you?

    if you’re unsure about abstract have a look at the language reference.

    I suggested abstract over virtual as people might not know you need to call super (even if you write it in the frameworks readme!)

    #6538

    codifies
    Participant

    here is an example of keeping your drawing to 16:9

    [/crayon]
    #6539

    APC
    Participant

    codifies,

    I know how to write abstract methods, I would like you to expand on your idea.

    #6540

    codifies
    Participant

    I’m sure you can work it out for yourself…

    #6543

    codifies
    Participant

    canvas.Scissor=New Recti( Xoffset*scaleX,Yoffset*scaleY, (960+Xoffset)*scaleX, (540+Yoffset)*scaleY )

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

You must be logged in to reply to this topic.