Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to develop a simple multi-Activity Android game using Marmalade SDK. I looked at the SDK samples and found that most of them are a single view (Android Activity) apps.

The Navigation model in Android is a stack-like model where views are pushed and popped.

I can't find whether Marmalade has a similar model or it uses a different approach.

would you please explain this to me and provide tutorials and samples to navigation in Marmalade if possible ?

Thanks

share|improve this question
add comment

3 Answers

up vote 0 down vote accepted

Marmalade compiles single code for multiple platforms. So you can't find Android Activities or iOS UIViewController in Marmalade code.

If you still wish to have access to Activity on Android e.g. implement SSO login with Facebook on Android then you should use EDK extension that provide direct access to Android and iOS

If you just develop game then you have to programs view system your self.

First time it took few hours to programs

Here are class declarations from my apps. I am not happy with them but it is real code that works for me.

class CButton;
class CScreen{
public:
enum{
    HIT_TOUCH,
    HIT_MOVE,
    HIT_RELEASE,
    HIT_BOOM,
    HIT_BOOMMOVE
};
CIwArray<CButton*> buttons;

CButton * touchButton;
int touchId, touchUniqueId;

CScreen();
virtual ~CScreen();
virtual void init(){}
virtual void terminate(){}
virtual void dispatch(int event);
virtual void touch(int id, int uniqueId, int x, int y);
virtual void release(int id, int uniqueId, int x, int y);
virtual void swipe(int id, int x, int y);
virtual void hit(int id, int power, int type, int x, int y, int old_x, int old_y);
virtual void hitFlash(int x1, int y1, int x2, int y2);
virtual void render();
};
class CButton{
public:
int eventId;
bool bvisible;
uint32 color;
CButton();
virtual ~CButton();
virtual bool testhit(int x, int y) = 0;
//virtual bool touch(int id, int unique, int x, int y);
//virtual bool release(int id, int unique, int x, int y);
virtual void render() = 0;
};





class CScreenGame: public CScreen{
public:
enum{
    EVENT_BACK,
    EVENT_PAUSE,
    EVENT_UNPAUSE,
    EVENT_HI
};
bool btouch;
int touchX, touchY;
class CGame * game;

char debugText[4096];

CButton * window;
CButton * buttonBack;
CButton * buttonPause;
CButton * buttonUnpause;
CButton * buttonNext;

CScreenGame();
~CScreenGame();
virtual void init();
virtual void terminate();
virtual void dispatch(int event);
virtual void touch(int id, int uniqueId, int x, int y);
virtual void swipe(int id, int x, int y);
virtual void hit(int id, int power, int type, int x, int y, int old_x, int old_y);
virtual void hitFlash(int x1, int y1, int x2, int y2);
void hit3D(int id, int power, int type, int x, int y, int old_x, int old_y);
virtual void render();
void transform(int x, int y, CIwVec3 & dir);
};



class CScreenMain: public CScreen{
public:
enum{
    EVENT_GAME,
    EVENT_CREDITS,
    EVENT_EXIT,
    EVENT_GIFT,
    EVENT_WEBSITE,
    EVENT_MORE_GAMES,
    EVENT_INTERESTIAL
};
CScreenMain();
virtual void dispatch(int event);
virtual void render();
};

class CScreenCredits: public CScreen{
public:
enum{
    EVENT_BACK
};
CScreenCredits();
virtual void dispatch(int event);
virtual void render();
};
share|improve this answer
    
A similar approach to yours is used in the blocslot game found in the SDK examples forlder Marmalads\VersionNumber\examples\games\blockslot –  Mina Samy Oct 7 '12 at 13:59
add comment

this is a post quite old but I got an answer for you. To easily work with Marmalade in the game field I would suggest you to use the brand new engine called IwGame (http://www.drmop.com/index.php/iwgame-engine/). I'm working for the porting of an Android game of mine and I started 2 months ago. It's really simple to learn and it's powerful. It's build on Marmalade so you can use all the knowledges you already learned but more, you can use a great engine to improve and speed development. For your specific question: IwGame use the "scene" method. Each Android activity could be translate in a scene. Each scene is easily build using the powerful XOML language and you can pass from a scene to another with few lines of code. For any more info, please ask.

Zapp

share|improve this answer
    
Thanks for the answer, I checked the new IwGame on Dr Mop before, but I believe it's not mature yet, anyway I'll try it, but can you tell me more about the navigation in Marmalade ? thanks –  Mina Samy May 14 '12 at 7:28
    
I'm sorry but my knowledge of Marmalade is almost completely based on IwGame –  Zappescu May 18 '12 at 10:05
add comment

The question is quite old, but I think it's better to answer an unanswered question than just leave it.

Android doesn't need a loop to continuously render the views, it automatically invalidates the views at each frame. Marmalade doesn't follow this approach. You need a game loop in Marmalade which runs once every frame.

The approach I follow and which is also recommended by Marmalade is to use UI files for every view. UI files are like XML layouts in Android, where we can create our views statically. The UI file is called on runtime and set as current view using the following method -

 IwGetUIView()->SetModal(CIwUIElement* view);

If you see the structure of UI files, you can see that every view is a subclass of CIwUIElement (Same as View class in Android). IwGetUIView() returns the current root view or whatever it's called. This statement can be compared to setContentView() of Android.

Similarly you can call RemoveElement() method to remove the view. I instead just set it's visiblity to false, as it's less prone to error.

One thing you need to remember is you need to call IwGetUIView()->Render(); and IwGetUIView()->Update(int32 deltaMS); in your app's Render() and Update() functions, which gets called at every frame.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.