Game Development Community

Click on sprite to make it disappear

by stillhawk · in Torque Game Builder · 06/15/2007 (8:46 pm) · 6 replies

In my TGB Project, I have several images loaded into Static Sprites. They are all set to Full.
I want the player to click on an image and make it disappear. I guess I have to go into the game.cs and write some code. Can anyone tell me how to do that?

Thanks,
George

#1
06/16/2007 (1:52 am)
Stillhawk

I am new here so dont know the total script but if you check out the shooter tutorial there is a function which makes the ship invisible when a enemy collides with it and then visible when spawn function is called.

you just have to combine it with mouseclick function, which I dont know yet.
#2
06/16/2007 (7:05 am)
Hey Wicked Sunny,

Thanks for trying to help. I'll look at the shooter again. I tried what I thought would work but it didn't. I am not even clear where in the game.cs to put the code. Since I want to have several levels, I'm beginning to think I should have a level.cs.

Maybe I'll post the code and see if that can get more help.

G
#3
06/17/2007 (3:50 am)
Give your static sprite the "ClickInvis" class and throw this script in your game.cs.

I have a call to setEnabled(false) commented out, if you want the object to be completely disabled (won't do collision, mouse events, etc, again until you call setEnabled(true) on it).

function ClickInvis::onLevelLoaded(%this, %scenegraph)
{
   // we need to set the scenewindow to mitigate the mouse events
   SceneWindow2D.setUseObjectMouseEvents(true);

   // now we can set this object to receive mouse events
   %this.setUseMouseEvents(true);
}

function ClickInvis::OnMouseUp(%this, %modifier, %worldPosition, %clicks)
{
   // set our object to invisible
   %this.setVisible(false);

   // use this to completely disable the object
   //%this.setEnabled(false);
}
#4
06/17/2007 (8:18 am)
Thanks Matthew

even I will note this down for future reference.
#5
06/17/2007 (8:20 am)
Thanks so much Matthew,

I finally gave up on trying to build my game using TGB. Too much scripting for a novice like me. I switched to The Game Factory 2 and have accomplished a lot in a few hours. I think that TGB and other GarageGames software are powerful and very worthwhile for people who know how to code.

TGB 1.5 Beta sounds like something that might work for me, but I'll have to wait for the final release.

One thing that I really like about TGB is the opportunity to develop for both PC and Mac. Down the road, I will come back and give it a try.

Good luck to all.

G
#6
06/17/2007 (8:43 am)
Stillhawk

I have tried game factory before, its easy to use but has lots of limitations.

like you cannot import your own music and sounds to make standalone games and its not royalty free, you have to use their logo..

You will have to buy MF2 developer that will cost 300 $ currently out of my range.

if you are playing around for fun its ok, but if you are serious about games which you would like to sell, that limitation will become a big problem later on.

I am very bad with scripting as well, I tried almost every game maker out there online.

But I think if you are serious about game making you will have to learn scripting. Currently I am taking c,c++ classes so that I can understand torque properly.

I bet if you take even 5 basic classes of c++ you will be able to catch torque script.

once you catch torque script, you will be able be able to use torque engine to create 3d games in future.

Its like toiling and learning something now for future boons.

but then it depends on exactly what you seek and how serious you are about game making.