1 decade ago
by kaleong
Hi everyone,
HTML5 game is just part of my iPhone app, the app would show some information before they play the game , I know that a game is contained in a UIWindow, my question is : is that anyway to close the game after win/lose and back to app(the previous UIWindow) ??
Also, can the game tell the app the result or can pass some variable to app??
Thanks a lot!!
1 decade ago
by Philip
This should be possible, but it's a little hard to explain. For my game I just implemented the menu etc. in js. Was not that hard. But I don't know what you want to do, so depending on the case the pure js solution might not work.
For communication between js and obj-c look into the JS_* classes. There you will see how to use the native object in js to talk between js and obj-c.
1 decade ago
by kaleong
@Philip
my problem are :
pass variable(some game elements, e.g. difficulty) from obj-c to impact when player launching the game in app
after game over, how do the game close down?(something like this.close()?), and back to app(also come back with BOOL gameWin = true/false to app)
Is it possible? Thanks a lot :)
1 decade ago
by Philip
It's possible. But you have to do all the hard work yourself, there isn't anything that will fix this for you.
Look into the JS_TouchInput.m to see how you can register callbacks from obj-c to js. The other classes with the JS_FUNC function should tell you the rest.
1 decade ago
by kaleong
@Philip
Thanks for your help, starting reading the class, but how about the close game function?? Is that available in impact?????
Thanks : )
1 decade ago
by kaleong
Not such hard work.
First, you have to create a new class based on JS_BaseClass, implement some JS_FUNC(functionName) (e.g. you created a JS_ABC.h/m)
Then, in impact side,
var obj = new native.ABC()
obj.functionName(paramYouProvide)
getter and setter are both worked normally
On the close game side, make a function which would disable the UIWindow init with impact class, all done~
Page 1 of 1
« first
« previous
next ›
last »