moveTo
by Lukas Macura · in iTorque 2D · 04/07/2009 (5:38 am) · 9 replies
Hi,
we find that this small example works well on PC, but on iPhone or iPhone simulator, all sprites are created, but only few (random) are moving, where is problem?
function TSSceneGraph::onLevelLoaded(%this)
{
$sceneGraph = %this;
$boardPos = "-89 -28";
%this.createStone();
}
function TSSceneGraph::createStone(%this)
{
%hndl =
new t2dStaticSprite() {
sceneGraph = %this;
class = "";
imageMap = "kameny_ImageMap";
frame = getRandom(1,30);
canSaveDynamicFields = "1";
Position = ($boardPos.x + getRandom(0,150)) SPC ($boardPos.y ); // set up tile position
size = "60 60";
Layer = "20";
};
%hndl.moveTo($boardPos.x + getRandom(-100,300) SPC 500,50,true,false);
%this.schedule(500, "createStone");
}
we find that this small example works well on PC, but on iPhone or iPhone simulator, all sprites are created, but only few (random) are moving, where is problem?
function TSSceneGraph::onLevelLoaded(%this)
{
$sceneGraph = %this;
$boardPos = "-89 -28";
%this.createStone();
}
function TSSceneGraph::createStone(%this)
{
%hndl =
new t2dStaticSprite() {
sceneGraph = %this;
class = "";
imageMap = "kameny_ImageMap";
frame = getRandom(1,30);
canSaveDynamicFields = "1";
Position = ($boardPos.x + getRandom(0,150)) SPC ($boardPos.y ); // set up tile position
size = "60 60";
Layer = "20";
};
%hndl.moveTo($boardPos.x + getRandom(-100,300) SPC 500,50,true,false);
%this.schedule(500, "createStone");
}
#3
04/08/2009 (11:35 pm)
What Dan said.
#4
04/08/2009 (11:45 pm)
thanks, it works now, we was confused because some object was moving and some not
#5
04/30/2009 (9:50 am)
I had the same problem and I'm curious as to why some objects will move and some won't. Also sometimes none move and sometimes a few move. The fact that it's not consistent is aggravating.
#6
Although setUsesPhysics() should be known as setUsesPhysicsSometimes() because the mUsesPhysics variable never actually gets initialised; which accounts for the "hey this works sometimes, but not other times"
You can set this to always init to be false in the t2dSceneObject constructor.
05/04/2009 (10:31 am)
I recommend re-building the TGB_Game.exe, defining PUAP_OPTIMIZE for the PC version if thats where you do your development on. That way you dont get ( as many ) surprises when running your game on PC then iPhone. Although setUsesPhysics() should be known as setUsesPhysicsSometimes() because the mUsesPhysics variable never actually gets initialised; which accounts for the "hey this works sometimes, but not other times"
You can set this to always init to be false in the t2dSceneObject constructor.
#7
05/04/2009 (10:58 am)
Ah I didn't realize the sometime part, that clears up why this issue has been so very annoying for me because it's been unpredictable.
#8
It's seems kinda tricky to do cause the physics is so tightly integrated with a sceneObject; for instance if you take a look in t2dSceneObject::integrateObject, you'll notice that updateLocalPhysics wont get run if setUsesPhysics is false, but further down getParentPhysics().updateTickPosition() and getParentPhysics().updateTickRotation() still get run; which updates SOME physics. Seems like disabling physics would take more of a surgeon's scalpel
The whole mUsesPhysics thing seems to be added in as a quick optimization hack; its not properly init'd and it doesnt work with the object serialization included in t2dsceneobject
05/04/2009 (11:06 am)
I also found that even with physics set to false, objects will sometimes update their physics for some actions because they didnt wrap enough checks around the physics processing in objects. It's seems kinda tricky to do cause the physics is so tightly integrated with a sceneObject; for instance if you take a look in t2dSceneObject::integrateObject, you'll notice that updateLocalPhysics wont get run if setUsesPhysics is false, but further down getParentPhysics().updateTickPosition() and getParentPhysics().updateTickRotation() still get run; which updates SOME physics. Seems like disabling physics would take more of a surgeon's scalpel
The whole mUsesPhysics thing seems to be added in as a quick optimization hack; its not properly init'd and it doesnt work with the object serialization included in t2dsceneobject
#9
05/30/2009 (1:02 pm)
Bug logged and fixed for v1.2.1
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft
As such you must enable physics on the object that is intend to be driven by moveTo through the corresponding script function call