Script issue
by HugoMatsumoto · in iTorque 2D · 06/06/2011 (10:12 am) · 1 replies
Hi guys,
I'm new on iTGB and I'm making a game with these configuration:
- Torque Version: TGB_1.75 and iTGB_1.4
- Target Platforms: PC, iPad, iPhone
- Develop program: Codeweaver for win 7 and Xcode for mac
- xcode 4.0.1 and iOS 4.3
- iphone 3GS to test
I'm getting strange behaviour on variables using torque script. But only for iTGB
The script is not stable, and when I tested a version without PUAP_SCRIPT_CHANG, it worked fine, but crashed after load 3 levels.
I got these strange behaviour with torque script( on shipping default build for iphone device):
- Sometimes variable using as parameter, is null.
e.g: click on position "-10 -10" of the screen and after on "-25 -6" and got the following result:
print from engine when onMouseDown was called "onMouseDown [-25][-6]"
All of code was working fine for TGB version. The problem is only with iTGB on iphone device
Am I doing something wrong? Something must be wrong..
Anyone can help me?
Thanks.
I'm new on iTGB and I'm making a game with these configuration:
- Torque Version: TGB_1.75 and iTGB_1.4
- Target Platforms: PC, iPad, iPhone
- Develop program: Codeweaver for win 7 and Xcode for mac
- xcode 4.0.1 and iOS 4.3
- iphone 3GS to test
I'm getting strange behaviour on variables using torque script. But only for iTGB
The script is not stable, and when I tested a version without PUAP_SCRIPT_CHANG, it worked fine, but crashed after load 3 levels.
I got these strange behaviour with torque script( on shipping default build for iphone device):
- Sometimes variable using as parameter, is null.
function ParticleManager::CreateAll(%this)
{
for(%iIndex = 0; %iIndex< 5; %iIndex++)
%this.Create("ExplosionParticle");
..
}
function ParticleManager::Create(%this, %sParticleName)
{
echo("["@%sParticleName@"]"); // sometimes prints [].. and the didn't create a particle
..
} - The most recent bug was on mouseDown callback. The callback time is ok, but the parameter of touch position always is "locked" in the fist callback:e.g: click on position "-10 -10" of the screen and after on "-25 -6" and got the following result:
print from engine when onMouseDown was called "onMouseDown [-25][-6]"
function t2dsceneWindow::onMouseDown(%this, %mod, %wPos, %mClicks)
{
echo(%wPos); // print "-10 -10" (wrong value)
%ret = "";
if ($clickDown!=true) {
$clickDown=true;
echo(%wPos); // print "-10 -10" (wrong value)
if($MatIsStopped){
%iTotal = $Game::Units.getCount();
if(%iTotal > 0){
for(%i = 0; %i <= %iTotal; %i++)
{
echo(%wPos); // print "-25 -6" (right value)
%ret = VerigySpecial(%wPos);
}
}
}
}
} the solution was to change the name of param and set the old variable as atual:function t2dsceneWindow::onMouseDown(%this, %mod, %wPosition, %mClicks)
{
%wPos = %wPosition;
..
} - Sometimes the local variable of a loop change the value inexplicably. To solve this problem, I changed the variable "%x" of first function to another.for(%x = 0; %x < 10; %x++){
echo(%x); // 0
SomeFunction();
echo(%x); // 3.. omg.. this is wrong!
}
function SomeFunction(){
for(%x = 0; %x < 3; %x++){
// do anything
}
}All of code was working fine for TGB version. The problem is only with iTGB on iphone device
Am I doing something wrong? Something must be wrong..
Anyone can help me?
Thanks.
About the author
Torque 3D Owner Drew Parker
I posted a fix for this here:
http://www.garagegames.com/community/resources/view/21806
Please let me know if it works for you.
Best of luck!