Behaviors not being loaded on device?
by John Vanderbeck · in iTorque 2D · 04/29/2012 (3:30 pm) · 12 replies
I have a custom behavior that I dynamically add to an object in script. Everything works fine in the simulator, but when I try running on my device it acts like the behavior was never loaded.
Anyone seen this?
Anyone seen this?
#2
04/29/2012 (4:07 pm)
There is a flag that you have to set in the level file to enable the onUpdate callback (I think). Personally I never saw the advantage of behaviours.
#3
I set the flag. In the simulator the onUpdate runs fine. It doesn't run at all on my iPad.
As for why? Well it seemed the easiest way to go about doing what I wanted, which is a constant animation of the objects alpha value over time. What other method would you suggest?
04/29/2012 (4:09 pm)
@ScottI set the flag. In the simulator the onUpdate runs fine. It doesn't run at all on my iPad.
As for why? Well it seemed the easiest way to go about doing what I wanted, which is a constant animation of the objects alpha value over time. What other method would you suggest?
#4
04/29/2012 (4:15 pm)
You could achieve the same with a function and a schedule? I tried behaviours but found the onUpdate (every 33ms) to be a performance inhibitor and preferred to have more control. As they say ... your mileage may vary :)
#5
04/29/2012 (4:16 pm)
Don't you have to set the flag USE_COMPONENTS for the device build (memory might be failing me here)?
#6
04/29/2012 (4:17 pm)
I haven't looked into schedules. I'll take a look at the docs and see if that will work. Sounds like it would, based on the name :)
#7
That appears to be defined by default.
Scott, could you possibly give an example of scheduling? I found the docs for it in the TGB docs, but I can't get it to work.
But the method never gets called.
04/29/2012 (4:36 pm)
Quote:
Don't you have to set the flag USE_COMPONENTS for the device build (memory might be failing me here)?
That appears to be defined by default.
Scott, could you possibly give an example of scheduling? I found the docs for it in the TGB docs, but I can't get it to work.
%tile = new t2dStaticSprite()
{
Class = "Tile";
};
%tile.schedule(1000, "testSchedule");
function Tile::testSchedule(%this)
{
echo("testSchedule");
}But the method never gets called.
#8
When I run this on the simulator the scheduled method gets called as expected. On my iPad it does not.
04/29/2012 (5:31 pm)
So ironically i'm having the same problem as with the behavior :(When I run this on the simulator the scheduled method gets called as expected. On my iPad it does not.
#9
Sorry I usually can't be much of help because I'm still on itgb 1.2.
But definitely use schedule instead of onupdate as much as possible (when it makes sense of course). Schedules are better on performance usually.
@John - Haven't tested the function on your post but I believe it should work.
The advantage of using object scheduling like the example above is if the objects get deleted before the schedule is called the schedule also gets deleted.
Here's a very simple example.
04/29/2012 (6:03 pm)
All these problems... I just close my eyes and pretend they don't exist :).Sorry I usually can't be much of help because I'm still on itgb 1.2.
But definitely use schedule instead of onupdate as much as possible (when it makes sense of course). Schedules are better on performance usually.
@John - Haven't tested the function on your post but I believe it should work.
The advantage of using object scheduling like the example above is if the objects get deleted before the schedule is called the schedule also gets deleted.
Here's a very simple example.
function main()
{
// Run this schedule after 1 second.
// You can replace 0 with an object name to associate this schedule
// with an object.
$scheduleID = schedule(1000, 0, foo, %arg1);
// To cancel the schedule
// cancel($scheduleID);
}
function foo(%arg1)
{
echo("Foo");
}
#10
How strange is that. Schedules appear to not function on iPad3. This is a pretty show stopping bug for me :(
04/29/2012 (6:16 pm)
Yeah I have rewritten things to use schedule instead, and it works -- on the simulator and my iPhone4. It does not work on my iPad3.How strange is that. Schedules appear to not function on iPad3. This is a pretty show stopping bug for me :(
#11
04/30/2012 (6:18 am)
@John - Is there a different in the OS or SDK versions between your iPhone 4 and new iPad?
#12
The actual script engine should be no different across all the iDevices. Can you put debug in from the top down to where you expect to see things - just to see that the scripts are executing in order.
04/30/2012 (1:23 pm)
@John, my gut tells me that there is something not quite right in your iPad3 code. It's possible there is some error that is stopping your main.cs from running.The actual script engine should be no different across all the iDevices. Can you put debug in from the top down to where you expect to see things - just to see that the scripts are executing in order.
Torque Owner John Vanderbeck
VanderGames
So I added an exec call for the behaviors I need and now they are being loaded, but the onUpdate is never being called.