[solved] onLevelLoaded call is delayed
by jarruda · in iTorque 2D · 08/04/2011 (9:03 am) · 1 replies
I have some very strange behavior showing up when using a class for a t2dAnimatedSprite with a t2dTrigger.
I'm attempting to implement a collectible for my player. The setup is that I have a sprite that the player collides with but there is no collision generated for. I did this by creating a trigger on the sprite when the sprite is created:
When this code is in place, onLevelLoaded is NOT called until my player collides with the sprite for the first time. If I remove all of the code except the echo from the function, then onLevelLoaded is called when you would expect it.
Anyone have any ideas?
[SOLVED]
So I figured out the issue, and it's nothing to do with the code not actually executing at the proper time. I was using tail -f console.log in order to see the log output in real time. It looks like TGB doesn't flush the console buffer every time it writes to the file, so I was actually seeing one log line in arrears. If I closed the game, the rest of the log would be flushed and I would indeed see onLevelLoaded called when it should have been.
GarageGames: you guys should really get iT2D's console window working again. Really makes debugging a PITA without it.
I'm attempting to implement a collectible for my player. The setup is that I have a sprite that the player collides with but there is no collision generated for. I did this by creating a trigger on the sprite when the sprite is created:
function ABJump::onLevelLoaded(%this, %sceneGraph)
{
echo("ABJump::onLevelLoaded called");
%this.trigger = new t2dTrigger()
{
// Trigger fields
onEnter = "true";
onStay = "false";
onLeave = "false";
// SceneObject fields
scenegraph = %sceneGraph;
class = "BlockTrigger";
size = %this.size;
};
%this.trigger.mount(%this);
}When this code is in place, onLevelLoaded is NOT called until my player collides with the sprite for the first time. If I remove all of the code except the echo from the function, then onLevelLoaded is called when you would expect it.
Anyone have any ideas?
[SOLVED]
So I figured out the issue, and it's nothing to do with the code not actually executing at the proper time. I was using tail -f console.log in order to see the log output in real time. It looks like TGB doesn't flush the console buffer every time it writes to the file, so I was actually seeing one log line in arrears. If I closed the game, the rest of the log would be flushed and I would indeed see onLevelLoaded called when it should have been.
GarageGames: you guys should really get iT2D's console window working again. Really makes debugging a PITA without it.
Community Manager Michael Perry
ZombieShortbus