HELP~~~ :( About whack tutorials
by Apppothk · in iTorque 2D · 10/12/2010 (3:52 am) · 2 replies
when i run the program . the mouse will lost in the game and i can't click the mole in the game:(
i use ITorque 1.4 version. and my OS is window 7.
i use ITorque 1.4 version. and my OS is window 7.
game.cs
function startGame(%level)
{
exec("./mole.cs");
exec("./respawnPoint.cs");
exec("./moleLevel.cs");
Canvas.setContent(mainScreenGui);
new ActionMap(moveMap);
// moveMap.bind(joystick0, xaxis, "joystickMoveX" );
// moveMap.bind(joystick0, yaxis, "joystickMoveY" );
// moveMap.bind(joystick0, Zaxis, "joystickMoveZ" );
moveMap.push();
$enableDirectInput = true;
activateDirectInput();
enableJoystick();
//Time to start game is measured from the very entry point, until now
%runTime = getRealTime() - $Debug::loadStartTime;
echo(" % - Game load time : " @ %runTime @ " ms");
sceneWindow2D.setUseObjectMouseEvents( true );
sceneWindow2D.loadLevel(%level);
}
//---------------------------------------------------------------------------------------------
// endGame
// Game cleanup should be done here.
//---------------------------------------------------------------------------------------------
function endGame()
{
sceneWindow2D.endLevel();
moveMap.pop();
moveMap.delete();
}
function oniPhoneChangeOrientation(%newOrientation)
{
%new = "Unkown";
if(%newOrientation == $iDevice::constant::OrientationLandscapeLeft)
{
%new = "Landscape Left (Home Button on the right)";
}
else if(%newOrientation == $iDevice::constant::OrientationLandscapeRight)
{
%new = "Landscape Right (Home Button on the left)";
}
else if(%newOrientation == $iDevice::constant::OrientationPortrait)
{
%new = "Portrait (Home Button on the bottom)";
}
else if(%newOrientation == $iDevice::constant::OrientationPortraitUpsideDown)
{
%new = "Portrait Upside Down (Home Button on the top)";
}
echo("newOrientation: " @ %new);
}
function oniPhoneTouchDown( %touchCount, %touchX, %touchY )
{
}
function oniPhoneTouchUp( %touchCount, %touchX, %touchY )
{
}
function oniPhoneTouchMove( %touchCount, %touchX, %touchY )
{
}
//Luma: Tap support
function oniPhoneTouchTap ( %touchCount, %touchX, %touchY )
{
}mole.cs
function mole::onAdd(%this)
{
// enable mouse events for the mole so we can easily determine when it is clicked on
%this.setUseMouseEvents( true );
}
function mole::onMouseDown(%this, %modifier, %worldPosition, %mouseClicks)
{
if( %this.getAnimationName() $= ("moleOut" @ %this.moleColor) )
%this.playAnimation( "moleIn" @ %this.moleColor );
}
function mole::onAnimationEnd(%this)
{
if( %this.getAnimationName() !$= ("moleOut" @ %this.moleColor) )
{
// after deleting the old mole schedule a respawn
// >%this.sceneGraph< is the level
%this.sceneGraph.schedule( 2500, "spawnMole");
%this.safeDelete();
}
}respawnPoint.cs
function respawnPoint::onLevelLoaded(%this, %level)
{
%level.respawnPointSet.add(%this);
}
function respawnPoint::onLevelEnded(%this, %level)
{
if( isObject( %level.respawnPointSet ) )
%level.respawnPointSet.remove(%this);
}moleLevel
function moleLevel::onLevelLoaded(%this)
{
%this.respawnPointSet = new SimSet();
}
function moleLevel::onLevelEnded(%this)
{
%this.respawnPointSet.delete();
}
function moleLevel::spawnMole(%this)
{
echo("sdfasdf");
// find a spawn point
%respawnPointIndex = getRandom( %this.respawnPointSet.getCount()-1 );
%respawnPoint = %this.respawnPointSet.getObject( %respawnPointIndex );
// select a color for the mole
%color = getRandom(2);
if( %color == 0 )
%color = "Orange";
if( %color == 1 )
%color = "Green";
if( %color == 2 )
%color = "Pink";
// create a new Mole
%mole = new t2dAnimatedSprite()
{
sceneGraph = %this;
class = "mole";
layer = 4;
size = "44 78";
};
// play right animation according to the color
%mole.playAnimation("moleOut" @ %color);
// save the selected color as dynamic field
%mole.moleColor = %color;
// set the position of the mole to the position
// of the respawn point
%mole.setPosition( %respawnPoint.getPosition() );
}datablock.cs
datablock t2dSceneObjectDatablock( respawnPointDatablock )
{
class = "respawnPoint"; // the class that will be associated with the object
layer = 5; // the render layer
size = "72 72"; // the size of the object
};About the author
#2
10/13/2010 (4:35 am)
The problem has been sloved . i think it is the window 7 problem. when i using mac os to run the program , it is no problem.
Employee Michael Perry
ZombieShortbus