Trying to make an image appear for half a sec when a button is pressed, then disappear.
HappyGOLUCKY
Member, PRO Posts: 102
hey guys. I need help
So, have you guys ever seen a gun fire and a puff of fire comes out as soon as the trigger is pulled and the bullet comes flying out? well if you know what I'm talking about that's exactly what I'm trying to replicate. So the image (fire) is invisible when the game starts. Then when you push the button the image of the fire appears for half a sec then disappears. Making it look pretty sweet.
thank you in advance.
Answers
Hi @HappyGOLUCKY and welcome to the Forums and GSC.
THere's a couple of ways to get the result you're after; here's one way:
Add into your firing button Rule, after the bullet Spawn behaviour, an Animate Behaviour (in a Timer set to After a fraction of a second perhaps) which includes your puff of smoke/fire sequence of images.
@DeepBlueApps have created a fine program called Explosion Generator (I thought it was free but I now see you do pay for it but such a small sum) which is well worth checking out (I mean to say, you'll easily be able to make your fire/smoke animation frames using it).
http://www.deepblueapps.com/?s=explosion+generator&x=-1220&y=-47
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
You could also trigger a nice little particle effect at the tip of your gun that includes a muzzle flash and some rising smoke.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
@gyroscope Hi and thank you for answering.
I'm having trouble doing what your instructions say. Heres what I have, correct me if im wrong. In my button actor I have a rule that says if touch is pressed do spawn actor (bullet), then under that I have a timer as you suggested, and in that timer I have spawn actor (puff of fire) , and under that within timer I have animate (also not sure if loop and restore actor image when done is supposed to be checked. Unfortunately this is not working. Could I be doing something wrong?
thanks,
Happy
If you have that image / actor already in the scene, but invisible, you COULD do as follow:
create a game Attribute (integer - default 0, called for example muzzleflash) then in the fire trigger, or wherever you call your actual fire event, add to the rule an "change attribute" and set game.muzzleflash set to 1, add timer, chosse "after" from the drop down and give the duration you want this muzzle flash to be seen (e.g. 0.3 ) add an "change attribute" set game.muzzleflash set to 0.
Then go to your flash image, add an rule that says
if attribute "game.muzzleflash" = 1
do stays empty
and in the otherwise section you add an "change attribute" that says
self.alpha = 0
that should be it
I hope it is understandable what i wrote here... still not very good in english
@3DMA hey, quick question
where you say do stays empty how do I input that ?
Sorry for not explaining it easier.
As soon as you click "create rule" you have the 2 areas. The first area is where you put something that should happen, if the rule is true, the second area (usually is closed, you have to open it by clicking the little triangle) is the one that says "otherwise do this"
What i meant is that in this case the first area stays empty, nothing else... and expand the second area (otherwise) and there place the rule that says self -> colour -> alpha = 0
I hope it´s better now :-)
@3DMA thanks for the detail. now its still not working here's what I have.
so under my button actor I have a rule that says** if touch is pressed** then do change Attribute. In change Attribute I have set: game.muzzelflash to: 1
then (still in touch is pressed rule) I have a timer under change attribute.
The **timer is set to after 1 second **
then inside the Timer I have set: game.Muzzelflash to: 0
Now in my fire or muzzelflash actor
I have a rule **when all of the following is happening **
if game.muzzelflash = 1
do (nothing typed or inserted here)
else
change Attribute
set: self.color.alpha to: 0
and i dragged my muzzelflash actor to the scene and made it invisible
what could I be doing wrong?
you need to leave it visible... it will be invisible by it´s rule ;-)
@3DMA Still not working
I changed it to visible. why?
Every time i click the button nothing is showing up.
Here's a quick demo I made for you, there might be some stuff you can extract from this . . .
Link: https://www.mediafire.com/?ap6g578265xectj
very confused
nothing seems to be working.
I´m sorry to say that, but some basic knowledge or more information of what is going wrong exactly can help us to actually help you. We explain step by step what to do, @Socks even takes the time to create an demo of what he explained.
What is it that you don´t understand?
The effect you would like to archive is fairly simple and done in a minute by following one of the above mentioned ways.
Maybe you have a closer look again on what was written above (either socks or my version) and create a clean new project only to try to recreate it there... once you understand how it works you can easily implement it in your game.
@3DMA
I'm very new to GS (1 day)
Ive followed the steps you and previous others have put out. Its just not showing up the image (fire or muzzelflash) is not appearing when I push the button.
I very much appreciate everyone's help.
Ok. And did you check the demo that socks gave you?
@3DMA
I tried to open the file on gs and it didnt work
It's very late here already and I'm about to go to sleep. Tomorrow I can prob telling more. In the meantime you can maybe post screenshots of the behaviors of the affected actors and your game attributes. Maybe we can see there what is going on.
@3DMA
(the first image is the top half and second image is the bottom half)
This is @gyroscope 's way (Image top half) -->http://s000.tinyupload.com/?file_id=10626282174148973582
(Image bottom half) ----> http://s000.tinyupload.com/?file_id=00004212408746027416
This is your instructions
(button rule) ----> http://s000.tinyupload.com/?file_id=05801652052550928967
(Muzzelflash actor) ---> http://s000.tinyupload.com/?file_id=61861700932460268403
Thank you for taking the time to look at what might be wrong. I apologize for my noobness.