Just bought Torque 2D for the iPhone, whats next ?
by mario Thaler · in iTorque 2D · 08/27/2009 (4:28 pm) · 5 replies
Hello Forum,
(skip) Intro:
i would not call myself a programmer, i do some Flash AS3 coding and thats about it.
I totally fell in love with the iphone, so i made my first app (a simple sample Player for Translation purposes) it took me quiete a while
to get i done (written in objective C / Xcode) but now its finished and waiting for approval.
For my next App i want to make something more like a 2D game, with collision detection, gravity and all that fancy stuff.
I had a look at cocos 2D but i found it hard to get started, so i did a bit of searching and found iTGB.
I just bought it and started playing around with it, i kind of get the idea how it works and i am sure i could build the game i want with it.
But than i read about the performance issues, and what I understood is that its good not to use this and that and do better this and that (right, i have no idea).
I really want to get started and would love to use (and learn) TorqueScript, as it feels more comfortable (coming from AS3) then getting really into objective C (my first app is kind of a "copy and paste code you find on the web or in books and make it work" thing)
But than on the other hand i do not want to rewrite everything in objective C (or whatever language i dont know enough) for better performance...
Chorus:
Now my questions:
I read people are combining iTGB with C ++ (or even including the chipmunk engine)
- How and where is this all done ? in XCode or in TGB ?
- what should i do ? learn TorqueScript, or objecitve C or both ,or do something completely different ?
i am from germany, so please excuse my english..
Any tip, idea, experiences from you guys would help, thanks !
(skip) Intro:
i would not call myself a programmer, i do some Flash AS3 coding and thats about it.
I totally fell in love with the iphone, so i made my first app (a simple sample Player for Translation purposes) it took me quiete a while
to get i done (written in objective C / Xcode) but now its finished and waiting for approval.
For my next App i want to make something more like a 2D game, with collision detection, gravity and all that fancy stuff.
I had a look at cocos 2D but i found it hard to get started, so i did a bit of searching and found iTGB.
I just bought it and started playing around with it, i kind of get the idea how it works and i am sure i could build the game i want with it.
But than i read about the performance issues, and what I understood is that its good not to use this and that and do better this and that (right, i have no idea).
I really want to get started and would love to use (and learn) TorqueScript, as it feels more comfortable (coming from AS3) then getting really into objective C (my first app is kind of a "copy and paste code you find on the web or in books and make it work" thing)
But than on the other hand i do not want to rewrite everything in objective C (or whatever language i dont know enough) for better performance...
Chorus:
Now my questions:
I read people are combining iTGB with C ++ (or even including the chipmunk engine)
- How and where is this all done ? in XCode or in TGB ?
- what should i do ? learn TorqueScript, or objecitve C or both ,or do something completely different ?
i am from germany, so please excuse my english..
Any tip, idea, experiences from you guys would help, thanks !
#2
Thanks so much, i dive into the ConsoleFunctions.
Just to make sure i got you right, the ConsoleFunctions are part of TGB and i just have to read the manual to find my way what they are and how to use it, right ?
mario
08/27/2009 (4:52 pm)
wow - that was fast !Thanks so much, i dive into the ConsoleFunctions.
Just to make sure i got you right, the ConsoleFunctions are part of TGB and i just have to read the manual to find my way what they are and how to use it, right ?
mario
#3
08/27/2009 (5:01 pm)
Yea their part of TGB. Unfortunately their is next to zero documentation on how to do anything in C++ for TGB. It's pretty tough going in the beginning. I'll see if I can write a resource about console functions in the next week. Until then just open up xcode and do a search in the project for ConsoleFunction. From there you can find lots of examples. Without C/C++ knowledge it might be a bit difficult understanding parameters and other stuff so you will have to brush up on your C/C++ at least to beginner level.
#4
I didnt expect this one to be easy, but hey, we do not have to do mammoth hunting for
a living anymore, so a bit of a challenge wont hurt.
Hopefully my next Post in 6 month is "check out my number 1 selling app i made with iTGB" ;)
Thanks for the quick and helpful support,
mario
08/27/2009 (5:16 pm)
Ok, thank you.I didnt expect this one to be easy, but hey, we do not have to do mammoth hunting for
a living anymore, so a bit of a challenge wont hurt.
Hopefully my next Post in 6 month is "check out my number 1 selling app i made with iTGB" ;)
Thanks for the quick and helpful support,
mario
#5
Think of it like the iPhone UIView animations (since you've done Objective C stuff). You just tell it what to do and let the system handle the how. Let TGB handle all the number crunching and let your script worry about simple things, and "triggering" the big stuff(i.e. write a script function that tells the engine what to do, don't write a huge math/physics function to calculate something in script).
08/28/2009 (9:15 pm)
Definately make your game design event-driven. I don't know how flash handles things, but you want to let Torque handle as much as it can in code, and just set variables update GUIs and stuff from script.Think of it like the iPhone UIView animations (since you've done Objective C stuff). You just tell it what to do and let the system handle the how. Let TGB handle all the number crunching and let your script worry about simple things, and "triggering" the big stuff(i.e. write a script function that tells the engine what to do, don't write a huge math/physics function to calculate something in script).
Torque Owner Bret Patterson
1. From the very beginning optimize ALL artwork. Everything should be square and a power of 2 if possible. Also everything should be as small as possible. Artwork optimization is really critical on the iphone. I wouldn't make ANY sprites bigger than 128x128 or you're likely to need some heavy duty tweaking to get it within the max memory requirements and performance. 64x64 sprites are ideal.
Start by writing my game entirely in Script and test frequently to see the performance impact of everything I added (on physical iphone, not simulator or pc). This way when I added something and the perfomance took a nose dive I would know exactly what it is. I'd make note of it and then continue on writing the game in script.
After you get your game done, or you reach a point where the game performance just can't be made any better with pure script, I'd then start to move pieces into C++ code. I'd use the list made above to prioritize what to move and would transition to C++ as needed in the following manner.
1. Start with biggest performance impact functions.
2. Convert these functions to ConsoleFunctions and write them in C++. This is the easiest script -> C++ conversion that you can do and will buy you a ton of performance improvement for AI and complex logic.
Once you've done the above it's possible that your performance will be good for most types of games. IF not then continue below.
Take the script behavior that has the most performance impact, or the most logic in onUpdate etc, and convert that behavior to a C++ component behavior. This will remove the script callbacks every few frames for the onUpdate that kill performance. This is where things will start getting pretty intensive from a programming perspective, but the above steps of converting to ConsoleFunctions should of eased you into it so this will be much easier.
At this point you should theoretically be able to get almost any game performing really well. If it's not then it's likely either bad programming or bad artwork.
General scripting guidelines:
Never use onUpdate callbacks as you're likely going to have to convert it to C++. If you need to do something periodically then use schedule to schedule a callback instead.
If you find yourself make loops in script that iterate over a bunch of objects keep this function in mind as it's likely to need conversion to c++. ConsoleFunctions are pretty easy to do once you get the basic concepts down.