Joystick controls
by rennie moffat · in General Discussion · 06/23/2009 (9:50 am) · 1 replies
I want to use joystick controls in a game for the iPhone.
However, I am wondering, if I used a joystick, plugged into my mac, would that be an accurate tester?
However, I am wondering, if I used a joystick, plugged into my mac, would that be an accurate tester?
About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
Torque Owner rennie moffat
Renman3000
this is the code for a joystick behaviour.
what I am wondering is where in it is the tilt, or amount of pulling in one direction occurring. See I am thinking regaurding various degrees of tilt will have various degrees of "gravitational" effect (mainly velocity) on the ball. I am sorry but I cannot see where that would go, is that something I need to add in I suppose?
if (!isObject(AlignToJoystickBehavior))
{
%template = new BehaviorTemplate(AlignToJoystickBehavior);
%template.friendlyName = "Align To Joystick";
%template.behaviorType = "Joystick Input";
%template.description = "Face the object to the direction a joystick is pointing";
%template.addBehaviorField(xAxis, "The joystick's x-axis", keybind, "joystick0 rxaxis");
%template.addBehaviorField(yAxis, "The joystick's y-axis", keybind, "joystick0 ryaxis");
%template.addBehaviorField(turnSpeed, "The speed to rotate at (degrees per second). Use 0 to snap", float, 0.0);
%template.addBehaviorField(rotationOffset, "The rotation offset (degrees)", float, 0.0);
}
function AlignToJoystickBehavior::onBehaviorAdd(%this)
{
if (!isObject(moveMap))
return;
moveMap.bindObj(getWord(%this.xAxis, 0), getWord(%this.xAxis, 1), "moveX", %this);
moveMap.bindObj(getWord(%this.yAxis, 0), getWord(%this.yAxis, 1), "moveY", %this);
%this.xVal = 0;
%this.yVal = 0;
}
function AlignToJoystickBehavior::onBehaviorRemove(%this)
{
if (!isObject(moveMap))
return;
moveMap.unbindObj(getWord(%this.xAxis, 0), getWord(%this.xAxis, 1), %this);
moveMap.unbindObj(getWord(%this.yAxis, 0), getWord(%this.yAxis, 1), %this);
}
function AlignToJoystickBehavior::moveX(%this, %val)
{
%this.xVal = %val;
%this.updateMovement();
}
function AlignToJoystickBehavior::moveY(%this, %val)
{
%this.yVal = %val;
%this.updateMovement();
}
function AlignToJoystickBehavior::updateMovement(%this)
{
%targetRotation = mRadToDeg(mAtan(%this.yVal, %this.xVal)) + %this.rotationOffset;
if (%this.turnSpeed == 0)
%this.owner.rotation = %targetRotation;
else
%this.owner.rotateTo(%targetRotation, %this.turnSpeed);
}