Game Development Community

Can I call a schedule in the game.cs? (solved)

by rennie moffat · in iTorque 2D · 04/10/2011 (12:15 pm) · 11 replies

Is it possible to call a scheduled event in my game.cs?


Thanks

About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
04/10/2011 (12:23 pm)
Can you give an example for clarification?
#2
04/10/2011 (12:32 pm)
Well, I am actually using iTGB, with in that game.cs are native onIPhoneTouchEvents(), up, down, move etc. You can program all sorts of stuff in here, like pinch zoom, drag etc. One thing I can not get going is a schedule tho...

if I use an existing parameter (%touchCount), a created global or local, sceneWindow2d... no matter the pointer I put ahead of the schedule call my game does not function.


So, is there a way to call a schedule from the game.cs?



#3
04/10/2011 (12:41 pm)
What I usually do for those cases, is take the code I want to execute and move it to it's own function, w/ parameters, etc. In the onIPhoneTouchEvent function I just call that function. This way it's not tied to the event function.. So later, if I want to use that same function without the event, to get the functionality out of it, I can call the function directly.
#4
04/10/2011 (12:45 pm)
Hmmm ok, I will try that.

What kind of pointer would you tho. I am doing a few things right now.


example
function oniPhoneTouchDown( %touchCount, %touchX, %touchY ) 
{
doThisFunction();
}

///or...
function oniPhoneTouchDown( %touchCount, %touchX, %touchY ) 
{
%touchCount.doThisFunction();
}

Sorry for asking, just doing a few things now.
Regardless...
Thanks!
#5
04/10/2011 (12:51 pm)
If needed, I usually track things outside of just the touchCount as in the last example. So usually I end up with something like
function oniPhoneTouchDown( %touchCount, %touchX, %touchY )   
{  
doThisFunction();  
}

Don't forget though, you can track whatever you need.. If you need some parameters on your function to get more information into it, that's available for you too. So you can end up with a function that will mimmick a touch just fine.

#6
04/10/2011 (4:04 pm)
Right just pass them through. So if I wanted %val, set in the touch function, passed to the doThisFunction, just do.






:Thanks!
#7
04/12/2011 (2:31 pm)
@smally, or whomever.

I have finally gotten around to this... the problem comes up tho as follows

In the console:
game/scripts/game.cs (525): Unable to find object: '' attempting to call function 'schedule'

So, it is going to my function, designed by me, but when inside and as it calls the schedule, it can not.
The function is exactly like this....
function setInfoSheetDataObjectsSchedule(%this)
{
	%this.schedule(1000, setInfoSheetDataObjects);
}




not sure why that won't call.
#8
04/12/2011 (4:08 pm)
is setInfoSheetDataObjects a function?

function setInfoSheetDataObjectsSchedule(%this)  
{  
     %this.schedule(1000, setInfoSheetDataObjects <-- is this a function?);  
}

and when calling setInfoSheetDataObjectsSchedule, make sure that the object your passing in is valid.

That's all I can glean from the short example. Remember also, there are two scheduling functions. One that's global and one that's object based.

#9
04/12/2011 (4:19 pm)
Right,
I just figured it out. I am now using the global schedule and placed in a the correct parameters.
Thanks!


schedule( t , objID or 0, functionName, arg0, ... , argN )
#10
04/12/2011 (5:04 pm)
Well, glad that helped.. You could also use the object based one too, just make sure the parameters are correct ;)
#11
04/12/2011 (5:18 pm)
Thanks smally.


:))(