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.

iOS and MacOS / [iOS TEMPLATE] Gekko Template (iAD, HUD, GameCenter, SV controller)

Author
Message
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 10th Oct 2012 06:09 Edited at: 10th Oct 2012 06:12
As i promised this is the Template i wanna gift to all AppGameKit iOS users.
It include:

- iAD
- HUD progress with title and subtitle
- ShowAlert with title and subtitle
- GameCenter with LeaderBoard and submit score
- Some bonus functions of my personal VIEWS MANAGER

How to use:
- Remember to add your bundle sign id
- Renew your profiling files or be sure they are ok
- Go to iTunes Connect to activate iAD
- Go to iTunes Connect to activate GameCenter and create at least 1 leaderboard
- Read my REM in the code to understand some things

Thanks :
Much thx goes to Ancient Lady that solved the orientation problem.

Enjoy!!!!

Long life to Steve!

Attachments

Login to view attachments
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 10th Oct 2012 09:24
Gekko, we need some indications what we must do to add GameCenter!

The AppGameKit template have changed for v108, so it's important to know what to add so that we can maintain the templates with every version
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 10th Oct 2012 10:33
spent a good deal of time trying to compare your template with the default AppGameKit one and trying to put in the bits & pieces to make GameCenter work.

But I FAILED miserable, and now I give up.

Also this template is already outdated as v108 is out.

As I said, what we need is a STEP by STEP guide, so that we can add Gamecenter in the future templates... until TGC include GameCenter commands!
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 10th Oct 2012 11:31 Edited at: 10th Oct 2012 11:32
Hmmm, why you use the 108??? It's beta, use 1076 on iOS.
I will give a look to it, but you just need the template run to see the Game Center in action and iAD.
I don't understand, can you explain?

Long life to Steve!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 10th Oct 2012 13:50
i only want to include Game Center. NOT iAD.

obviously I want to use 108 in the future because it has a ton of new commands.

your ready made template is good, but I just want to put the GameCenter bits in MY template!

I thought it would be easy and work at once, but i was wrong

you can leave the italian remarks in there as I can understand them too, no need to waste time translating!
erebusman
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 10th Oct 2012 17:07
Wow very nice job and thank you!

And I tend to agree to implement in the current working/supported version of 107 but for the community to maintain it could be rough

Of course documenting everything can be a pain... I'm currently working on the community wiki and its fairly painful hahah

Thanks for your hard work though very nice!

xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 10th Oct 2012 20:06 Edited at: 10th Oct 2012 20:06
Well, if you don't need iAD just don't call [SV ShowBanner] easy no?
The template i uploaded need to be used when you start a new project.
To use it you with an old project, you must start a new project and copy the files and differences step by step...
I did this the first time i got AGK.
For example, in my complete Template (i can't upload for obvious reason) there are :
- Socket with a server
- Database for users (real time app sales, run, online players, etc..)
- JSON parser
- XML parser
- Sprite Manager
- Window Manager
- Button Manager
- Sound Manager
- Music Manager
- Video Manager
- Option file
- AntiCrash
etc....

With this i wanna say, that as time goes by, you can have a great template that will work for much months and is easy to be updated step by step.

Long life to Steve!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 10th Oct 2012 23:00
Gekko keep in mind I don't know objective C, so like many other people, this is all new to me and very hard to do
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 11th Oct 2012 02:40 Edited at: 11th Oct 2012 02:41
Well, if you need help just ask.
I was sincere, in August 2011 when i started my adventure on iOS, i was completely in the dark with OBJ C, but i done something in C++. As i used many languages in my life so i convinced myself to use OBJ C, and i started from the examples from other peoples, adding some lines here and there.
After 1 month of tries and tests, you can understand it, and you will say : "Wow this is a very simple language!!".... WTF!!! ahahah...
When you mix it with C++ and AppGameKit Engine you have the power, and with the power comes the mon.... (monday?? naaaaa, ahaha)


Long life to Steve!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 11th Oct 2012 09:32
I will try checking again some other Obj-C tutorial how to do GameCenter maybe I have some better luck
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 16th Oct 2012 01:52
Hi BJ i see now this post....
A suggestion...
If you use another method to show the GC be careful to be sure that the view controller in in the AppGameKit appDelegate anyway.
Or you will never show it and you will go crazy as i gone crazy 1 year ago.

Long life to Steve!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 16th Oct 2012 11:12
I will check this it again as soon as AppGameKit 108 is final.

i also want to know if TGC has plans to put GameCenter and Openfeint in the next version
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 17th Oct 2012 06:27
Well i given a try to the new 108, but is too heavy in size for iOS.
And i think it must be at least optional with the libraries.
I tried some commands like:
Facebook (don't work) or bad info on how to use it
Twitter (i don't undesrtand how it work)
The rate ... already done.

I think that AppGameKit must go over this things...
3D commands are welcome, but the commands to use things that can be done in 10 lines in OBJ C, i think is better we help each other to use them.
Or maybe do a Facebook/Twitter additional LIB to include for example called :
- agkFace::connect();
- agkTweet:: connect();

So users can chose what to add.
What do you think?

Long life to Steve!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 17th Oct 2012 23:40
why is it heavy in size?
how bigger is it in comparison with 1076?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 18th Oct 2012 00:04
My home built Players have these sizes as used in the storage lists:
iOS v1076 - 2.7MB - 2.2MB App Size, 488KB data
iOS v1082 - 4.4MB - 4.0MB App Size, 488KB data
Android v1076 - 5.68MB - 5.32MB App, 368KB data
Android v1082 - 6.36MB - 6.00MB App, 368KB data

The values are for a newly installed Player, run but nothing broadcast to it.

As soon as you actually broadcast and run, the data size jumps way up, based on what you broadcast.

So, there is a basic difference of about 1.7MB in iOS and 680KB in Android for Tier 1 stuff.

I haven't built comparable Tier 2 projects in both versions for iOS and Android to see what the difference is there.

Cheers,
Ancient Lady
AGK Community Tester
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 20th Oct 2012 07:14
Well i done some test and i returned to 1074, files in 108 are too big cause you need to include other 10 libs.
I hope they can leave us the choice to include Facebook and Twitter as external lib.
The same with the others.

Long life to Steve!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 21st Oct 2012 12:54
how does "too big" compare with other non-agk apps that use the fb and twitter external libs?

if those other apps are "too big" too, then the problem is not agk related, it's just the way twitter and fb include libs are built
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 22nd Oct 2012 17:31 Edited at: 22nd Oct 2012 17:33
Yes when i say "big" i mean too big for a small lib.
Anyway the main problem for me is to do them optional and not required.
For example, i don't use AdMOB, i only use iAD, so why i have to include this lib??

I will try to study the Facebook and Twitter in another moment and maybe a will do a mini cpp file to include in the project to avoid 108 if they don't do them optional.



Long life to Steve!
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 7th Nov 2012 22:42
xGEKKOx, thanks for sharing the template
Works perfect and saved a lot of time (i'm on 1076 yet)

never give up
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 9th Nov 2012 14:50
Thx tornado!
If you need help don't hesitate to ask.

Long life to Steve!
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 11th Nov 2012 22:37 Edited at: 13th Nov 2012 09:49
well, it's time to ask

when i run the template, i got this in log:



any ideas on how to clean the log before submitting the app?

UPD: i discovered that template app closes when sent to background.I can't find the reason for such behaviour, seems to be bug or incorrect setting somewhere.

never give up
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 15th Nov 2012 19:31
Of course mate...
When you are in the Xcode, go to the left and press Xcode->Preferences
Now choose behaviors and choose all the things the console must show when :
- Run
- Debug
- On Device

and all the other options you want.
Do some test to understand how it works.


Long life to Steve!
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 15th Nov 2012 23:44 Edited at: 16th Nov 2012 08:24
xGEKKOx, that's not up to settings
to clarify, i see 3 issues;
1) i mean not the debug area, i mean when i run the template on my iPad/iPhone and press home button (or do the four-finger-close gesture) it just exits completely! app::appGetResumed() is never called. That's the problem for me and i'm not so good with Xcode to solve it.
I suggest app should fold to background, pause and then restore completely.

2) Minor problem is leaking objects, see code quote from log in my post before.

3) Template doesn't run in iOS simulator ("error: failed to attach to process ID 0")


thanks for your kind help

UPD: #3 is solved by cleaning project/resetting simulator/renaming Recources folder/setting debugger to GDB in scheme settings

UPD UPD: #1 is solved by setting "Application does not run in background=NO" in .plist file. feel myself foolish

never give up
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 16th Nov 2012 11:35
Ah ok....

Great you solved, i just see the questions only now!!
Usually i don't use the background cause iphone users hate when the phone go down on battery very fast.

For the leaking objects, don't pay too much attention to them, expecially if you use the "ANALYZE".
It will always find something, also in AppGameKit that it think will leak.

The log you see is normal, this is why i told you to don't log all but only the debugger/compiler errors.

Long life to Steve!
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 16th Nov 2012 13:12 Edited at: 16th Nov 2012 15:24
xGEKKOx,
Thanks for good news if this leaking does no matter, that makes your template even more extremely useful! In fact, it runs fast and this makes sense, GREAT thanks, again

cheers,

never give up
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 16th Nov 2012 20:35
Yes with my template you can exchange data from OBJ to AppGameKit cpp.
If you need the opposite way to exchange the cpp variables and use them in the OBJ, you can add to the template.h some extern variables.



Long life to Steve!
erebusman
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 17th Nov 2012 19:40
My newest project uses your template xGEKKOx ; I noticed one interesting thing right away.

The AppGameKit templates I had been using would not permit the user to play their own music while my app was running.

Using your template they can actually do that now.

Still waiting to hear if anyone has any orientation problems, crossing fingers that your template will fix that!

xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 19th Nov 2012 13:52 Edited at: 20th Nov 2012 15:22
Nice, never happened to me, but great!!!
Well, i have much other things for that template, but some as you can understand, i keep secret.
But if you need help on a specific thing, i will be proud to help and publish it.

Long life to Steve!
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 19th Nov 2012 21:40 Edited at: 19th Nov 2012 22:47
going further with quiz on your template is there a way to get the HUD to show up before the app::Loop passes a cycle? i mean I have nested loop within the main loop and this nested loop has sync() command, but HUD doesn't show up in this loop although other in-screen stuff do. What am I doing wrong?

never give up
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 20th Nov 2012 15:35
Hi Tornado...

This are some things you must know when operating with OBJ C and AppGameKit together.

- AppGameKit and OBJ C run on different threads so you must use some tricks

If you want to show something directly to the OBJ C without waiting the Sync() in the Loop you can choose one of these:

SV* is the variable we use to call function in UntitledViewController from C++...

1) [SV performSelectorOnMainThread .......] (and choose the selector and the rest of the command)
2) Call a function that call a [self FUNCTION] in the UntitledViewController always on main thread.

For the thing you wanna do i suggest the 1st point.

Another trick when you wanna show an UIImageView (for example) is :
UIImageView *im = .....;
When you finished to build the image, add in the way we know in my template...

[appDelegate.UntitledViewController.view addSubview: im];
[im setWantsLayer: YES];

This trick will show the image on the fly, without waiting, and to overwrite the AppGameKit Layout with some object by OBJ C.
This is the trick i use to show the Game Center Avatars in the AGK.


Long life to Steve!
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 21st Nov 2012 20:16 Edited at: 22nd Nov 2012 08:38
Hmm... my [absent] knowledge of objC makes me frustrated


just shows warning "Instance method '-setWantsLayer:' not found (return type defaults to 'id')

I'm sorry if I'm asking too much, but could you share couple of lines of code which would work actually for the ShowHUD function in your template?

never give up
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 23rd Nov 2012 13:05 Edited at: 23rd Nov 2012 13:35
No problem Tornado... ask whenever you want.

Ok....
You must know that when you use LOOPS you need to create pages that change the content on the loop itself.
For example:


If you use a method like this, you know that the sync is done every frame but launch the HUD 1 time and pass for the Sync.
I think that AppGameKit have its SYNC on the main thread of the app cause the NSTimer that refresh the view is on UntitledViewController.m

You can also call a function in this way but you will create too much functions...


In this case you need to modify just a bit the showHUD function as you need.
For example in this way...


In this way you do a personal HUD that respond on various reason directly on the main thread, and it must appear immediately.
Try!!

Long life to Steve!
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 25th Nov 2012 12:36
Gekko, thanks, that works!
Going further, what I can suggest adding to the template is customization of UIAlert function - could be useful or maybe you improve it for template v 1.1 if you find it so


UntitledViewController.h


UntitledViewController.m


in Template.cpp


never give up
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 26th Nov 2012 01:26 Edited at: 26th Nov 2012 01:38
Yes mate already done, if you need it i will show you my version with the TAG implementation.
Try to do it by yourself, use the tag when you do a alert (myAlert.tag = 10000 and if the alert in the clicked is the tag you want you can process as you done.

If you need, i have also the EditBox that work much better than the AppGameKit one and you can use it everywhere without the annoying WaitInput.
It also have the "Move View Up" when it goes under the half size of the device

Mine don't need loops checks, but go directly to the variable you need

But anyway i'm happy you are learning Obj C that is very useful, expecially for things "Utility" like this.
Mixed with the AppGameKit is a great power....

Now i suggest you another thing...
In the template.h you need now to add this:


In the template.cpp add this:


Another gift for you ... (this is the one i use for the GG Basic to choose the filename and description.
You can do the same using the nickname.
!!!! REMEMBER !!!!
You need that loop run without do nothing sometimes, until the PAGE is changed by the OBJ C Clicked function.
I suggest to use a stupid PAGE called "Idle" that do nothing.
if(Page == "Idle"){
//Fake page wait the page change again
}





So as you can see, you need to avoid the Loop too times, so better you do some struct that you can externalize in the .m code!!!

Do particularly attention to this, to learn another great thing:
UITextField* filename = (UITextField*)[_alert viewWithTag:18001];

We get it as a general Object, and we know what is it, so we declare it directly (UITextField*).
You can use this trick on other much Object. (In this case you know is an alert that include an edit view)

Enjoy!!!

Long life to Steve!
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 27th Nov 2012 06:54 Edited at: 27th Nov 2012 07:01
Thanks mate, I 'll come to implement it soon as I need some text input for the app
The other thing I'm stuck in is understanding how AppGameKit draws view and what is the view in which sprites are located.
I'm trying to create my own screenshot taking method with this code


But this returns blank white image saved to camera roll! I believe smth is wrong with rendering the view, maybe this method should be called after some preparations either i render the wrong view?

never give up
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 27th Nov 2012 11:44
Ok give me some hours and i will post you the way to use the CGContext mixed with the AGK.
When i return to home i will do it.
See you later.
(you are on the way, but there is something tricky to do, as AppGameKit use the GL under all layers).

Long life to Steve!
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 27th Nov 2012 17:06
Ok this is the way you can add a CGContext View to your app.


Simple eh???
Eheheh, in this way you can use CGContext as faster than using AppGameKit sprites to do points, lines, boxes, circles, texts....

Try and tell me if works for you too.
Enjoy!


Long life to Steve!
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 27th Nov 2012 19:20 Edited at: 27th Nov 2012 19:21
well, seems really easy and this makes mixing AppGameKit and XCode even more tasty

I've also found the solution for custom screenshot function, cause it's not UIKit but OpenGL screenshot method should be performed on iOs to get AppGameKit buffer to image, from XCode documentation


never give up
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 28th Nov 2012 16:04 Edited at: 28th Nov 2012 16:05
Ehi tornado, you know what we probably need???!!!
I asked to AppGameKit team to develope a function for PixelColors (as used for perfect pixel collision) but they didn't added it yet...
Do you think we can save a picture and re load with AppGameKit as a sprite?
I explain...
In the past i done a Karate game (an IK+ C64 clone) and i used to paint all the sprites with different clothes color.
I want to change colors pixel by pixel, selecting the color....
For example....
GetRGBA(int x, int y);
So...
if(R == 230) ChangeColor
or...
if(G > 40 && G < 150) ChangeColor
In this way we can change clothes to sprites and many other things.

I don't understand why AppGameKit team don't wanna introduce this function.
Do you think we can read immediately the image if we transform it with OBJ C?
Or we need to load images from the begin?

Long life to Steve!
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 28th Nov 2012 19:31
Gekko, i don't see the way to pass image back to agk from objC, bcause i don't know in which way image ID (uint) is assigned by agk to an image. if i could have look at agk::GetImage source that would give the answer probably.

never give up
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 29th Nov 2012 02:54
Well, if we open a PNG with the OBJ C, and we extract a pixel in array representation, and we change the colors using OBJ C, maybe if we save the new PNG in the bundle folder, we can load with the AGK.
But is stupid to read, write and read again. The reason is to do it in memory.
I will ask TGC Team to introduce this command again....
I think is extremely important in 2D games.

Long life to Steve!
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 30th Nov 2012 07:06
I would consider better asking TGC to unveil a few lines of code for image and sprite manipulation functions to bring better integration for Tier 2 with objC (and C++, obviously). They did this with FPS Creator in the past, i remember

If I knew the principle of sprite/image number assignment in AppGameKit, I would move the world

never give up
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 30th Nov 2012 19:57
Gekko, they will add pixel reading and writing soon, in the next version
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 1st Dec 2012 01:37
Where you read this?

Long life to Steve!

Login to post a reply

Server time is: 2024-11-21 13:01:23
Your offset time is: 2024-11-21 13:01:23