Monkey 2 App Methods

About Monkey 2 Forums Monkey 2 Programming Help Monkey 2 App Methods

Tagged: ,

This topic contains 5 replies, has 4 voices, and was last updated by  APC 2 years, 3 months ago.

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

    APC
    Participant

    Team,

    On Monkey X 1 we use these App important methods such as

    OnLoading, OnCreate, OnUpdate, OnRender OnSuspend, OnResume and more.

    In Monkey 2 I see OnRender and OnUpdate I did not see OnSuspend and OnResume that are important to mobile apps.

    Is there a guide in this forum where I can get the info? Does Monkey 2 follow the same structure of MX1 reganding this methods?

    For instance I had to call my own OnUpdate from OnRender because it was not called automatically.

    Below is the a portion of my code. You can down load it from here http://monkey2.monkey-x.com/forums/topic/monkey-2-sample-app-and-audio-issues/

    #6462

    nerobot
    Participant

    In my (incomplete yet) framework I go away from Window class, user know nothing about window – it hidden inside of my Application class that also don’t override monkey’s App class.

    Inside of Application we have needed callbacks.

    One way is to use OnUpdate, On… () virtual methods ,  other way is to use fields-as-func and subscribe to them . I preffer the second way because you shouldn’t extends class to use these callbacks .

    OnUpdate – I think it’s normally in monkey2 to call it from render.

    OnSuspend and OnResume logic you can extract from OnWindowEvent – see the docs.

    #6463

    APC
    Participant

    nerobot

    Thank you.

    In case I am working on a game my game class should extend View and not Window. does that also apply for mobile devices? Or it depends on the type of app I am developing.

    #6471

    Mark Sibly
    Keymaster

    A lot of OnBlah stuff that was in mx1 is now implemented as ‘signals’ in AppInstance, eg: Activated and Deactivated (probably more coming). You can ‘hook’ these up to your own handler like this (inside, say, your window’s constructor):

    App.Activated+=OnActivated    ‘Assumes there’s an OnActivated method/function somewhere!
    App.Deactivated+=OnDeactivated    ‘Assumes there’s an OnDeactivated method/function somewhere!

    For OnUpdate, it’s up to you how to update, easiest way is just to update inside OnRender but you can also create a timer, eg:

    New Timer( 60,OnUpdate )

    #6512

    cocon
    Participant

    I thought about this one as well as well, at first I thought that it was missing due to some sort of API economy.
    For example with “New” you replace the “OnLoad”, with “OnRender” you replace the “OnUpdate”.

    #6514

    APC
    Participant

    I posted a template here http://monkey2.monkey-x.com/forums/topic/monkey-2-app-template/ with suggestions from Mark and impixi.

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

You must be logged in to reply to this topic.