Behavior/mouse question
by Andrea Farid Marsili · in iTorque 2D · 02/22/2011 (11:21 am) · 0 replies
Can I use behavior designed for TGB with iTGB?
Where I have to put my behavior?
Have I to change the "onMouse" stuff in my behavior or mouse == touch?
I tried with the "MouseDraggable" behavior available for download here:
http://tdn.garagegames.com/wiki/TGB/Behaviors/Mouse_Draggable
And with another behavior by me:
My behavior work with TGB and with iTGB preview mode but if I try to build the xCode project nothing happened.
Where I have to put my behavior?
Have I to change the "onMouse" stuff in my behavior or mouse == touch?
I tried with the "MouseDraggable" behavior available for download here:
http://tdn.garagegames.com/wiki/TGB/Behaviors/Mouse_Draggable
And with another behavior by me:
if (!isObject(MouseRotableBehavior)){
%template = new BehaviorTemplate(MouseRotableBehavior);
%template.friendlyName = "Mouse Rotable";
%template.behaviorType = "Mouse Input";
%template.description = "Rotate an actor using the mouse";
}
function MouseRotableBehavior::onBehaviorAdd(%this){
%this.owner.setUseMouseEvents(true);
$initRotation = %this.owner.getRotation();
$rotPosX = %this.owner.getPositionX();
$rotPosY = %this.owner.getPositionY();
$initAngle = mAtan($mousePositionY - $rotPosY, $mousePositionX - $rotPosX);
}
function MouseRotableBehavior::onMouseDragged(%this, %modifier, %worldPosition, %clicks){
$mousePositionX = getWord(%worldPosition, 0);
$mousePositionY = getWord(%worldPosition, 1);
%myAngle = mAtan($mousePositionY - $rotPosY, $mousePositionX - $rotPosX);
%this.owner.setRotation(($initRotation + (%myAngle - $initAngle)) * 45);
}My behavior work with TGB and with iTGB preview mode but if I try to build the xCode project nothing happened.