Game Development Community

New to iTorque 2D, where can I find sample code?

by Timothy Powell · in iTorque 2D · 05/10/2011 (11:17 am) · 12 replies

After reading through the tutorials, everything seems simple enough. I'm an experienced C, C++, C#, and Java (mostly with android) developer, but I'm finding myself lost coming into iPhone developing. Is there any sample code beyond the Fish and Rain Tutorials? Is there a resource somewhere that someone could forward to me?

Thanks!

About the author

Recent Threads


#1
05/10/2011 (11:22 am)
Your best bet is to make a start then ask on here as you come up against an issue, there aren't currently any further in-depth resources on iTorque but they're planned for the future.

Is there anything in particular you'd like more information on? If you've been able to put up with Java you'll have no issues.

The main thing about Torque is it hides pretty much all iPhone specific code from you, you can use almost purely C++ when you're not writing in Torque Script and can easily wrap objective-c code into a C++ interface.
#2
05/10/2011 (11:29 am)
Thanks Alistair,

I guess the things I'm looking for would be:
how do I transition between scenes?
will all/most torquesript translate for iPhone use?
if so, is there more sample of general torquescript I can find somewhere?
#3
05/10/2011 (1:42 pm)
Quote:how do I transition between scenes?

You essentially need to know two key functions:

%level = "game/data/levels/Splash.t2d";

// %level is a string containing the path to your level
sceneWindow2D.loadLevel(%level);

// This cleans everything up and closes the level
sceneWindow2D.endLevel();

You must always call sceneWindow2D.endLevel before you load a new level, unless you are doing something advanced.

Quote:will all/most torquesript translate for iPhone use?
All of TorqueScript will run on iOS. If you are wanting to increase performance, you can write in C++ or Objective C.

Quote:if so, is there more sample of general torquescript I can find somewhere?
You will not find anything more general than the Overview and Simple sections under Scripting in the Official Documentation
#4
05/10/2011 (2:01 pm)
Thanks Michael! That was incredibly helpful!

Once I get my head around TorqueScript, I would be happy to write sample docs and do some technical Writing, I've stumbled across the wiki a few times and it seems completely devoid of anything that I'm looking for. What is the process for updating the wiki? (worked with a few major console developers before, each time using and updating the wikis, so I'm familiar with how, but not who has privileges to do so here)

I scanned over the documentation and found nothing on time based actions. How is time handled in Torquescript, is there a wait/pause/hold function?

Thanks for bearing with me guys :)
#5
05/10/2011 (4:06 pm)
@Timothy - Glad you like the link. TDN (the wiki you are referring to) is on life support. It has been compromised previously and had many of its features removed for security purposes. The bigger problem, as you noticed, is that it is not maintained. We have a few rock star community members who contribute, but not nearly enough to really fill out the sections (especially iT2D).

If you are interested in writing for the wiki, you will find the following links useful:

- How to write a tutorial

- Syntax Guide

- iTorque 2D Page (currently bare)

Any contributions to the docs would be GREATLY appreciated by myself and the rest of the community. As long as you have an account here, you should be able to log in to the wiki and start editing.

Timing is primarily handled through scheduling. There are two ways to schedule:

1. Global scheduling:

// Sample function
function doSomething()
{
  echo("Something");
}

function scheduleSomething()
{
   $doSomethingSchedule = schedule(1000, 0, "doSomething");
}

function

2. Object scheduling:

function Player::doSomething(%this)
{
   echo("Something");
}

function scheduleObjSomething()
{
    // Assume %obj has a Player class
    %obj.schedule(1000, "doSomething");
}

You can read more here: Scheduling Functions
#6
05/17/2011 (7:49 pm)
Edit:

got it working, I had stopped typing a function name to pick up a call earlier, and completely forgot to finish off the name. Caused all of my issues!
#7
05/17/2011 (9:57 pm)
Great! Glad you got it working =)
#8
05/21/2011 (4:45 pm)
Do the iPhone inputs register when one uses "Run Game"? up until now I have just been using mousedown/up/move/etc. When I try using oniPhoneTouchDown nothing registers. Is there a different way to use the iPhoneTouch inputs?
#9
05/21/2011 (5:20 pm)
They will only work on iOS, as long as you have multi-touch enabled.
#10
05/21/2011 (5:23 pm)
Awesome, thanks again Michael!

I have a question not necessarily related to TorqueScript, How do I set an object's collision shape to be that of the visible image? I scanned through the forum, still looking actually, and haven't found anything yet. Surely there is an option somewhere?

Will this affect the area that an object can be interacted with as well? If not, how do I set an object to only receive input on its visible parts?
#11
05/21/2011 (5:28 pm)
@Timothy - The best solution is to use the Collision Editor. This allows you to make collision shapes according to your image.
#12
05/21/2011 (5:31 pm)
Awesome! I can't believe I had completely forgotten about the collision editor. *facepalm*