Pop up text
by Robert Lanter · in Game Design and Creative Issues · 12/13/2007 (10:05 am) · 9 replies
I started with this resource to create a pop up text for the tutorial of my game:
http://www.garagegames.com/blogs/105/11116
However, I am having trouble getting any sort of pop up system to work in my game. The resource is obviously going to require some changing as I want just regular fonts with no animations so that it is easy for the player to read. I need help to figure out how to make this work. What i need it to do is to trigger specific messages when the player arrives at a certain locations (i.e. the player comes across a gap he needs to jump across and a message will pop up to say "press the space bar to jump across this gap")
Would adapting this resources logic work best for my game or should I find some other way of working this, and if so, what? Thank you in advance for any responses to this message.
http://www.garagegames.com/blogs/105/11116
However, I am having trouble getting any sort of pop up system to work in my game. The resource is obviously going to require some changing as I want just regular fonts with no animations so that it is easy for the player to read. I need help to figure out how to make this work. What i need it to do is to trigger specific messages when the player arrives at a certain locations (i.e. the player comes across a gap he needs to jump across and a message will pop up to say "press the space bar to jump across this gap")
Would adapting this resources logic work best for my game or should I find some other way of working this, and if so, what? Thank you in advance for any responses to this message.
#2
12/13/2007 (10:53 am)
Thanks for the reply :) I would appreciate if you could show me how you got it working. Been working on it for a while and i don't really understand how to work triggers
#3
12/16/2007 (9:23 pm)
Any information on how to use triggers to push and after a period of time pop a GUI?
#4
This code uses an object, but you could change it to display a gui.
12/16/2007 (10:55 pm)
I just found the old email I sent that had this code... if you want it to pop after a time use a schedule.This code uses an object, but you could change it to display a gui.
Quote:
About the script:
I used the default trigger in 1.5 to make this script. It spawns a
health item when you enter the trigger and deletes the health item
when you leave the trigger. This could be changed to display a sign
on the screen or something like that. I used the health item because
it already existed in 1.5. Its something quick and simple, it could
be done different ways of course, I just through this together kinda
quick.
Here is the code:
You need to save it as 'healthKitTrigger.cs' in the server folder.
And then add exec("./healthKitTrigger.cs"); in game.cs.
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// DefaultTrigger is used by the mission editor. This is also an example
// of trigger methods and callbacks.
datablock TriggerData(HealthKitTrigger)
{
// The period is value is used to control how often the console
// onTriggerTick callback is called while there are any objects
// in the trigger. The default value is 100 MS.
tickPeriodMS = 100;
};
//-----------------------------------------------------------------------------
function HealthKitTrigger::onEnterTrigger(%this,%trigger,%obj)
{
// This method is called whenever an object enters the %trigger
// area, the object is passed as %obj. The default onEnterTrigger
// method (in the C++ code) invokes the ::onTrigger(%trigger,1) method on
// every object (whatever it's type) in the same group as the trigger.
// Get the players position
%playerPos = getWords( %obj.getTransform(), 0, 2 );
// make a new position by adding 1 to the players y position, and 3
to the players z position
%pos = VectorAdd( %playerPos, "0 1 3" );
// Spawn the health kit item
%myHealthKit = new Item()
{
dataBlock = HealthPatch; // Use this datablock defined in health.cs
position = %pos; // Spawn at the position we made above
};
$deleteObj = %myHealthKit;
Parent::onEnterTrigger(%this,%trigger,%obj);
}
function HealthKitTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
// This method is called whenever an object leaves the %trigger
// area, the object is passed as %obj. The default onLeaveTrigger
// method (in the C++ code) invokes the ::onTrigger(%trigger,0) method on
// every object (whatever it's type) in the same group as the trigger.
$deleteObj.delete(); // Delete the health kit.
Parent::onLeaveTrigger(%this,%trigger,%obj);
}
function HealthKitTrigger::onTickTrigger(%this,%trigger)
{
// This method is called every tickPerioMS, as long as any
// objects intersect the trigger. The default onTriggerTick
// method (in the C++ code) invokes the ::onTriggerTick(%trigger) method on
// every object (whatever it's type) in the same group as the trigger.
// You can iterate through the objects in the list by using these
// methods:
// %this.getNumObjects();
// %this.getObject(n);
Parent::onTickTrigger(%this,%trigger);
}
#5
12/17/2007 (9:53 am)
Thank you very much for the help mb :) this should work very well for my game.
#6
Edit: Using this function to pop the dialog after a set period of time :
schedule(10000,0,Canvas.popDialog(popUp));
However, the schedule does not actually wait 10 seconds to pop the dialog. it just pops it the second i leave the trigger area
12/18/2007 (8:49 am)
Have another question, I got the pop up to work now but when it pops up the mouse appears on screen and won't allow to rotate the camera, this could be extremely problematic for the player, any idea how to prevent this from happening? currently the pop up is a Guicontrol and I'm using a GuiBitmapCtrl for the text and i think that is the problem but what could i use in place of these to accomplish the same goal of displaying the message but without it making it impossible for the character to rotate?Edit: Using this function to pop the dialog after a set period of time :
schedule(10000,0,Canvas.popDialog(popUp));
However, the schedule does not actually wait 10 seconds to pop the dialog. it just pops it the second i leave the trigger area
#8
12/20/2007 (9:35 am)
Thanks again mb you are a life saver. That worked perfectly.
#9
12/20/2007 (9:39 am)
Cool, glad to help.
Torque 3D Owner mb