Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Need Method to detect when game is sent to background

Author
Message
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 13th Jun 2012 19:25
I understand that having an actual 'Exit' option in an iOS based game is not standard. And having experienced serious delays getting to the devices app menu when I do use an exit button and call 'end' (after cleaning up everything), no matter how simple the app is, I can live with that.

But it is really necessary to have some method to determine that an app has been minimized or sent to the background.

On my Android, the game did go into pause and the GetResumed command works.

On Windows and Mac, when minimized, the game keeps playing. So some sort of function is needed to tell when that happens (google issue #312).

There definitely needs to be a way to check for going to the background and resuming in iOS so that appropriate action can be taken to start back up in the correct mode.

Cheers,
Ancient Lady
XanthorXIII
AGK Gold Backer
12
Years of Service
User Offline
Joined: 13th May 2011
Location:
Posted: 14th Jun 2012 05:17 Edited at: 14th Jun 2012 05:17
There is in iOS. GLBasic had the ability to do this and I'm fairly certain that TGC can do the same thing for theirs.
Lee and Paul should look at this
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html

The message they need to check for is applicationDidEnterBackground

and I believe there is one for Foreground.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 14th Jun 2012 16:04 Edited at: 14th Jun 2012 16:04
Thanks for the link, the changes can all be made in user code in Tier 2, simply add the function



to Core.m

On Windows we did have the app pause when it went to the background but it didn't feel right considering lots of Windows apps keep running in the background so we took it out for the first version. But again the changes can be made in a Tier 2 app by capturing the WM_ACTIVATE message in Core.cpp like so



And then only calling App.Loop() if g_bAppActive is true.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Jun 2012 16:44
Paul, great for Tier 2.

But we could use some help in Tier 1.

It exists with GetResumed for Android, which nicely pauses when sent to the background.

In Windows, since most of what we are programming is games, it should pause when it gets minimised. Same goes for the Mac.

And in iOS, we really do need to know when we have gone to the back and come forward. All other apps I've used recognize the condition and behave appropriately.

I will probably go straight Tier 2 in the future, but I wanted to get my first game done and out to multiple platforms. So I went Tier 1. That is the biggest selling point for AGK.

Cheers,
Ancient Lady
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 14th Jun 2012 17:04
I can't understand why everyone seems to be claiming that only T1 allows you to have your apps onto multiple platforms.

My T2 project runs on ios, windows, android & playbook without 1 line change in code.

Sorry but I had to state that fact.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Jun 2012 17:47
Of course, Tier 2 will run on multiple platforms. That is not what I meant.

The point I meant is that with Tier 1 you only have to do the actual coding once. Then do the bits to make it available on other platforms. Which, once you've done them once, go smoothly.

But with Tier 2 you need to do the coding for each platform.

Granted, if you do it right, most of the code between Windows and Xcode can be reused.

I haven't tried any Tier 2 programming for Android. I assume Tier 2 in Android is probably Java. The template doesn't seem to provide anything to start from, like for Xcode and VS.

I don't know about Playbook.

Cheers,
Ancient Lady
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 14th Jun 2012 20:20
You don't need to redo any coding.

you just copy the cpp in place and compile on the specific platform.

the effort needed is identical to the effort needed to copy the t1 bytecode and recompile.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 14th Jun 2012 20:22
its all done in c++ using the android ndk, no java recoding needed. just copy the cpp and recompile.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Jun 2012 20:49
Really? It's that easy? Darn it, I'll definitely go to Tier 2.

Naturally I'm about 95% complete with my current game. So, I'll finish it in Tier 1.

I just looked at the template.h and template.cpp in the Xcode and Android templates and they are the same! The key are the main.c (Android) and main.m (Xcode) files and the libraries they link to. Cool, I am dumb and should have looked more closely at this.

When I just tried to compile the template_android project I got a bunch of other errors (none of yours). All were complaining about stuff in 'C:/TGCSHARED/AGKWorkspace/GDKPro/libprojects..'. No such directories exist and this looks like it is trying to do stuff with GDKPro, not AGK. There were lots of other errors all about references not being found.

Here is an extract of some of errors (I couldn't include the entire log.txt file, it is too long for this post):


Cheers,
Ancient Lady
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 14th Jun 2012 20:58
in t2 you only need to check out template.cpp

just put your code in there, you don't need to alter the other files unless you want to customise how agk works internally.

i have a full game ready, which compiles on ios, android, windows & playbook without changing 1 line of code!!!

i am just waiting for the final playbook agk to come out so that i can release it on playbook.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Jun 2012 21:24
bjadams, what version of AppGameKit are you using?

I cannot get the android template to compile (as noted in previous post). I am using v1076.

Cheers,
Ancient Lady
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 14th Jun 2012 21:39
Quote: "When I just tried to compile the template_android project I got a bunch of other errors"


This may be another case of the template project not keeping up to date with the interpreter project. Try copying the Android.mk, Application.mk, main.c, and Core.cpp from the IDE\apps\interpreter_android\jni folder to the IDE\templates\template_android\jni folder.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 14th Jun 2012 22:02
i had to replace some files, just like paul suggested
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Jun 2012 22:27
Okay and I replaced 'interpreter.h' with 'template.h' in Core.cpp.

I also copied CoreForApp.h and did the same edit.

It reduced the errors:


And I get this error as well:


I naturally do a clean before each build.

Getting closer, but still not there.

Cheers,
Ancient Lady
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 14th Jun 2012 23:25
CoreForApp.h has lots of interpreter specific code so shouldn't be copied. If you don't have the original then just empty out all the functions in it so they read { } and return 1 if needed.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 15th Jun 2012 00:02
I wasn't sure about that one. I restored the original and now only have the 'recipe' error, probably caused by these in the compile:


Cheers,
Ancient Lady
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 15th Jun 2012 00:14
So, I copied the template.h file from the Xcode 4 ios template and renamed m_DeviceWidth and m_DeviceHeight to g_dwDeviceWidth and g_dwDeviceHeight and rebuilt.

And I edited the Android.mk to remove references to the interpreter.h file and replaced interpreter.cpp with template.cpp.

All happy now!

Whew!! Now I have a working template. I haven't tried to build anything real yet, or actually run it. But it builds.

This still doesn't help with the issue that started this thread.

I'm going to be showing off my WIP game to family for feedback this weekend. It would be nice to be able to show the full start up screens and such. But, since I cannot get the game to cleanly exit on iOS devices, I guess I'll have to use the Android to show that.

Cheers,
Ancient Lady
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 15th Jun 2012 12:08
would be nice to have an official guide or simple steps/list how to make a working android t2 template!!!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 15th Jun 2012 18:20
Or, they could just keep the templates up to date.

They are trying to get away from the template system and come up with a set of instructions. But it hasn't happened, yet.

Cheers,
Ancient Lady
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 15th Jun 2012 23:09
the problem i am facing right now is, should I rebuild the project using a new template every time a new build comes out, or are the actual templates always identical?

I have kept the templates from the first agk release, but i know that for example in the last release something must have changed in the templates because now we have true landscape mode.

i think agk need a dedicated docs - guide tech writer!
Alien Menace
AGK Developer
19
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Earth (just visiting)
Posted: 16th Jun 2012 08:50
I think this board needs to separate Tier 1 and Tier 2 into different forums.

Apps published: 3
Proteus
21
Years of Service
User Offline
Joined: 4th Oct 2002
Location: The Future
Posted: 31st Jul 2012 09:08
@Ancient Lady: I'm with ya... I've been trying to get a "working" T2 template for a couple of days now (out of the interpreter and the original android template) , (I've also commented @ http://code.google.com/p/agk/issues/detail?id=374&can=1&q=tier%202&sort=priority )... I really hope to get an answer from someone at TGC...

Is it possible for you to share your working template? I'd be extremely grateful

Thanks!

Diego "Proteus" Spinola
Electrical Engineer @ Hackeneering.com
Computer and Digital Systems Engineering
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 31st Jul 2012 16:39
Attached is my template_ios_xcode4 directory.

You will need to change the bundle identifier (it is set to my company).

It includes the tweaks for the minor disconnect between what AppGameKit thinks is LandscapeLeft/Right and what the iOS device does (as demonstrated by the displayed information when run) and the iOS specific bits to add an 'appGetResumed' call as described in another post in the iOS post.

Cheers,
Ancient Lady
AGK Community Tester

Attachments

Login to view attachments
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 31st Jul 2012 16:44 Edited at: 3rd Aug 2012 16:27
Oops!

@Proteus, I just reread your post and realized that I posted the wrong project.

Attached is the jni directory for my android template. It compiles, but I haven't been able to test it yet. My android device died and my new one is supposed to arrive any minute now. Feel free to try this one.

Basically, just replace your entire <androidpath>/AGK/IDE/templates/template_android/jni directory with the one in the zip file.

EDIT: I deleted the attachment because the compiled apk does not work on devices. Paul added a good template to the Your Products download page, use that one.

Cheers,
Ancient Lady
AGK Community Tester
Proteus
21
Years of Service
User Offline
Joined: 4th Oct 2002
Location: The Future
Posted: 1st Aug 2012 01:10
Thank you very much Ancient Lady,

I'm going to test the template ASAP (as soon as I get to my workstation), I'll report back by tomorrow morning =D

Thanks again

Diego "Proteus" Spinola
Electrical Engineer @ Hackeneering.com
Computer and Digital Systems Engineering
Proteus
21
Years of Service
User Offline
Joined: 4th Oct 2002
Location: The Future
Posted: 1st Aug 2012 07:39 Edited at: 1st Aug 2012 07:48
@Ancient Lady,

The Android template did build , but failed to execute on my Nexus S running android 4.1.1

here's the debug log from eclipse indicating the segfault:


Execution also failed on another device I tested , a tablet running android 4.03 (segfault)

Thank you once again Ancient Lady, I'll be reporting this on the other threads , hopefully we'll get some help from TGC soon on this subject =|

ps.I've attached the generated .apk (if anyone want to test a different device/android version)

Diego "Proteus" Spinola
Electrical Engineer @ Hackeneering.com
Computer and Digital Systems Engineering

Attachments

Login to view attachments
Proteus
21
Years of Service
User Offline
Joined: 4th Oct 2002
Location: The Future
Posted: 3rd Aug 2012 08:42 Edited at: 3rd Aug 2012 08:43
Since TGC answered our call , I'm doing my part and updating the relevant threads with the link to the solution:

Paul Johnston solved our problems @
http://forum.thegamecreators.com/?m=forum_view&t=199188&b=46&msg=2381156#m2381156

Diego "Proteus" Spinola
Electrical Engineer @ Hackeneering.com
Computer and Digital Systems Engineering

Login to post a reply

Server time is: 2024-03-29 10:45:52
Your offset time is: 2024-03-29 10:45:52