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.

Android / Adding images and working with Android Tier 2

Author
Message
PaulTR
11
Years of Service
User Offline
Joined: 25th Oct 2012
Location: Fresno, CA
Posted: 30th Oct 2012 19:36
So I've managed to get T2 working to the point where I have the Hello World application working. The next question I have is where to store my sprites for referencing in the game. I tried making a media folder in assets, and then NDK wouldn't build template.o, so I'm not sure what exactly I'm doing wrong, but I have been able to edit the print message and get that working.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 30th Oct 2012 21:25
Did you start from a working Windows Tier 2 app? If so, your media would have either been in the same directory as the final executable or a sub-directory under that one and you added that sub-directory to the load command. If this is the case, you should have your media in the assets directory or a sub-directory in that named the same as it is used in your app.

If you are starting from scratch with an Android Tier 2 project, then you put all your media in the assets directory. Or a sub-directory under that and use that sub-directory name in the load calls.

Simply creating a media directory in the assets directory should not cause the build to fail. What was the message in the log.txt file when the build failed?

Cheers,
Ancient Lady
AGK Community Tester
PaulTR
11
Years of Service
User Offline
Joined: 25th Oct 2012
Location: Fresno, CA
Posted: 30th Oct 2012 21:47
Actually I'm not sure what broke it, but I ended up just putting my image files into the assets folder and it worked fine. I'm playing around with the code now and fixing my errors as they come along, but I'll post if I run into something else that I can't get Thank you!
PaulTR
11
Years of Service
User Offline
Joined: 25th Oct 2012
Location: Fresno, CA
Posted: 30th Oct 2012 22:21
The next issue I'm having is including/creating objects into the Tier 2 code. I have two files, Asteroid.cpp and Asteroid.h, and I'm trying to call their constructor in the code but it throws out this error when I attempt to call the constructor:

Paul@Paul-PC /cygdrive/c/android/AGK/IDE/templates/template_android_t2
$ /cygdrive/c/android/android-ndk-r8b/ndk-build 2> log.txt
Compile++ arm : android_player <= template.cpp
SharedLibrary : libandroid_player.so
/cygdrive/c/android/android-ndk-r8b/build/core/build-binary.mk:378: recipe for target `obj/local/armeabi/libandroid_player.so' failed

The error message in the log is:

In file included from jni/../../../common/include/Common.h:290:0,
from jni/../../../common/include/agk.h:6,
from jni/template.h:5,
from jni/template.cpp:2:
C:/android/android-ndk-r8b/platforms/android-9/arch-arm/usr/include/jni.h:592:13: note: the mangling of 'va_list' has changed in GCC 4.4
./obj/local/armeabi/objs/android_player/template.o: In function `app::Begin()':
C:\android\AGK\IDE\templates\template_android_t2/jni/template.cpp:20: undefined reference to `Asteroid::Asteroid(unsigned int)'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libandroid_player.so] Error 1

----
My Asteroid.cpp is:


and Asteroid.h is


I am able to declare the memory space for an asteroid in the global declaration area with Asteroid tmpAsteroid1; but my error comes in when I add this line into the begin() loop: tmpAsteroid1 = new Asteroid(3);
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 31st Oct 2012 16:11
Did you add the Asteroid.cpp file to the <andproj>/jni/Android.mk file? It should be added between Core.cpp and template.cpp.

Files are not automatically included just because they are in the <andproj>/jni directory.

Cheers,
Ancient Lady
AGK Community Tester
PaulTR
11
Years of Service
User Offline
Joined: 25th Oct 2012
Location: Fresno, CA
Posted: 31st Oct 2012 23:13
Awesome, I didn't know about that.

I've updated Android.mk so that the LOCAL_SRC_FILES section looks like this:


I'm pretty sure that's right, and everything compiles now. I don't have my cable on me to test it since I'm in class, but it seems like it'll work. Thank you very much!

Also I had another question I was thinking about this morning; how do you guys implement Android menus with AppGameKit? I know the menu button is being depreciated, and I want to have a pause screen for my Asteroids game, but I don't know how to approach the problem other than having some sort of virtual button on the screen to pull up a menu, but then that takes up a bit of valuable screen space on a phone.

Thanks!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Nov 2012 15:24
Android menus are not supported as such in AGK. If you can find an Android library that lets you tie into the menus, it might work with AGK.

When I run an AppGameKit based app on my Android devices, the menu button does appear and lets me press it and it gets highlighted (same as the back button), but nothing actually happens.

I know the home button comes through as a raw keyboard value (27, I think). So maybe the menu one does too. Try making a simple program that checks for key presses and tells you what it detected and press the menu button until it shows what happens.

Cheers,
Ancient Lady
AGK Community Tester
PaulTR
11
Years of Service
User Offline
Joined: 25th Oct 2012
Location: Fresno, CA
Posted: 1st Nov 2012 17:40
Ah OK I'll look into that. Thanks for all your help AL! I've got something finally up and running. I'm rewriting my game since I had used virtual resolution instead of aspect ratios, but overall it's pretty much the same exact code, which is exciting. I had also used a keyboard originally, so I'm playing with the virtual inputs but this is what I have so far, so thank you!

TheTeenDevs
11
Years of Service
User Offline
Joined: 19th Aug 2012
Location:
Posted: 26th Dec 2012 00:25 Edited at: 26th Dec 2012 20:27
Never mind asking this in another separate thread:
I have this issue with other pages.... I have this in charactr.h

I have this in character.cpp

I then tried to put the function into the main program

Eclipse says it's fine but Cygwin gives this error:

and log.txt says:

I've tried everything and tried to emulate this post with character.cpp and character.h and android.mk which is all the info it had:
http://forum.thegamecreators.com/?m=forum_view&t=201167&b=46
Thanks in advance for the help!!!!!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 2nd Jan 2013 16:18
First, the print command you have in the 'createBall()' function will never appear. The agk:rint command is not a permanent, you need to call it every sync loop for it to appear. And you don't want to call the 'createBall()' function every sync loop.

But the main problem is that you aren't using the class properly.

In order to use the 'createBall()' function, you need to create an instance of a charactr object and then call the function using it. Something like this:


Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-03-29 15:35:06
Your offset time is: 2024-03-29 15:35:06