Swap Image on Mouse Up
by rennie moffat · in Torque Game Builder · 07/20/2009 (5:28 pm) · 2 replies
HI,
I am trying to create a magic 8 ball game where static sprite (the crystal ball), will, upon mouseUp Event, will display the users fortune. However I am confused how to achieve this. I have researched, and will continue to run tests but currently I adjusted the SwapImageOnCollsion Behaviour so it became onMouseUp, SwapImage. This is my code, it doesnt work tho, can someone point out my errors?
//-----------------------------------------------------------------------------
// Torque Game Builder
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
if (!isObject(SwapImageOnMouseUpBehavior))
{
%template = new BehaviorTemplate(SwapImageOnMouseUpBehavior);
%template.friendlyName = "Swap Image On MouseUp";
%template.behaviorType = "Effects";
%template.description = "Switches the image of an object when Mouse is clicked Up";
%template.addBehaviorField(image, "Fortune", object, "", t2dImageMapDatablock);
%template.addBehaviorField(frame, "The frame of the image to swap to", int, 0);
}
function SwapImageOnMouseUpBehavior::onBehaviorAdd(%this)
{
%this.owner.mouseUpCallback = true;
}
function SwapImageOnMouseUpBehavior::onCollision(%this, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts)
{
if (isObject(%this.image))
%this.owner.setImageMap(%this.image, %this.frame);
}
I am trying to create a magic 8 ball game where static sprite (the crystal ball), will, upon mouseUp Event, will display the users fortune. However I am confused how to achieve this. I have researched, and will continue to run tests but currently I adjusted the SwapImageOnCollsion Behaviour so it became onMouseUp, SwapImage. This is my code, it doesnt work tho, can someone point out my errors?
//-----------------------------------------------------------------------------
// Torque Game Builder
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
if (!isObject(SwapImageOnMouseUpBehavior))
{
%template = new BehaviorTemplate(SwapImageOnMouseUpBehavior);
%template.friendlyName = "Swap Image On MouseUp";
%template.behaviorType = "Effects";
%template.description = "Switches the image of an object when Mouse is clicked Up";
%template.addBehaviorField(image, "Fortune", object, "", t2dImageMapDatablock);
%template.addBehaviorField(frame, "The frame of the image to swap to", int, 0);
}
function SwapImageOnMouseUpBehavior::onBehaviorAdd(%this)
{
%this.owner.mouseUpCallback = true;
}
function SwapImageOnMouseUpBehavior::onCollision(%this, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts)
{
if (isObject(%this.image))
%this.owner.setImageMap(%this.image, %this.frame);
}
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.
#2
Program FilesGarageGamesTorqueGameBuilder-1.7.4documentationcontentdocumentationReferenceInput Interaction.html
07/21/2009 (7:09 am)
Hey rennie, check out your local documentation for a full rundown. Usually when I run into issues like this, I'll navigate to my documentation directory and do a search within files on the content directory... In this case, I did "onMouseUp" and got back the "Input Interaction.html" file.Program FilesGarageGamesTorqueGameBuilder-1.7.4documentationcontentdocumentationReferenceInput Interaction.html
function sceneWindow2D::onMouseUp( %this, %modifier, %worldPos, %mouseClicks )
{
}
Torque Owner Timothy Castagna
TK Games LLC
function SwapImageOnMouseUpBehavior::onCollision
to this
function SwapImageOnMouseUpBehavior::onMouseUp