Quick fire questions
by Anthony Ratcliffe · in Torque Game Builder · 01/12/2008 (12:16 pm) · 4 replies
Just bought the game, few questions
are there any updated tutorials or resources as 1.6 seems to have little to no support
for my end of year project we are to create a duck hunt style game clicking on a flying duck to kill it and add one to the score.
these are the things i wish to include.
joystick support a standard playstation controller, i found a tutorial on the network.
http://tdn.garagegames.com/wiki/TGB/ScriptTutorials/JoystickSetup
however it doesnt go into great detail on how to set it up i managed to get the buttons to work but not the dpad
i'd also like to add a standard pause screen much like this
http://tdn.garagegames.com/wiki/Torque_2D/StandardTutorials/Basics/PauseScreen
but again am finding the detail a bit sparse.
also any idea where i can get free art work
are there any updated tutorials or resources as 1.6 seems to have little to no support
for my end of year project we are to create a duck hunt style game clicking on a flying duck to kill it and add one to the score.
these are the things i wish to include.
joystick support a standard playstation controller, i found a tutorial on the network.
http://tdn.garagegames.com/wiki/TGB/ScriptTutorials/JoystickSetup
however it doesnt go into great detail on how to set it up i managed to get the buttons to work but not the dpad
i'd also like to add a standard pause screen much like this
http://tdn.garagegames.com/wiki/Torque_2D/StandardTutorials/Basics/PauseScreen
but again am finding the detail a bit sparse.
also any idea where i can get free art work
About the author
#2
01/14/2008 (9:11 am)
For the fish game tutorial, perhaps the problem is that your duck is moving along the X axis (assuming left to right) so in onWorldLimit the spawn function call will never trigger because it's set for "bottom". Change it to "right" and see if that fixes things.
#3
so insted i game up with this
function duck::onMouseDown( %this, %modifier, %worldPos, %mouseClicks )
{
%this.setLinearVelocityY(20);
}
so when it is clicked on it flys to the bottom of the screen, however this is not working but theres no script errors any help?
01/14/2008 (11:38 am)
Ah thanks it worked however the animation problem persistsso insted i game up with this
function duck::onMouseDown( %this, %modifier, %worldPos, %mouseClicks )
{
%this.setLinearVelocityY(20);
}
so when it is clicked on it flys to the bottom of the screen, however this is not working but theres no script errors any help?
#4
This should allow your duck to receive mouse events and solve both the animation and velocity problems.
01/25/2008 (6:51 pm)
Try updating your onLevelLoaded to look like thisfunction duck::onLevelLoaded(%this, %scenegraph)
{
%this.startPositionY = %this.getPositionX();
%this.setLinearVelocityX(getRandom(%this.minSpeed, %this.maxSpeed));
%this.setUseMouseEvents(true);
SceneWindow2D.setUseObjectMouseEvents(true);
}This should allow your duck to receive mouse events and solve both the animation and velocity problems.
Torque Owner Anthony Ratcliffe
function duck::onLevelLoaded(%this, %scenegraph)
{
%this.startPositionY = %this.getPositionX();
%this.setLinearVelocityX(getRandom(%this.minSpeed, %this.maxSpeed));
}
function duck::onWorldLimit(%this, %mode, %limit)
{
if(%limit $= "bottom")
{
%this.spawn();
}
}
function duck::spawn(%this)
{
%this.setPosition(getRandom(26, -21), %this.startPositionX);
%this.setLinearVelocityX(getRandom(%this.minSpeed, %this.maxSpeed));
}
this is the code i am using but it seems not to respawn any ideas?
another problem i have come across:
using the whack a mole tut i wish to change the animations from one called duckalive to duck dead however i cant seem to adapt the code this is wat i am using atm, and the script doesnt seem to register
function duck::onAdd(%this)
{
// enable mouse events for the mole so we can easily determine when it is clicked on
%this.setUseMouseEvents( true );
}
function duck::onMouseDown(%this, %modifier, %worldPosition, %mouseClicks)
{
if( %this.getAnimationName() $= ("duckalive") )
%this.playAnimation( "duckdead");
}
// dead is when the duck is killed
// alive animation is when its alive
regards ant