Loving my first day in Construct 2.
I have a spaceship thrusting around a star field using physics, and I want to show the afterburner sprite when the mouse is down.
I tried spawning it on an image point on the spaceship graphic, but of course, this spawns on every frame the mouse button is down, quickly spawning hundreds of afterburners
How would I approach this so that the afterburner graphic is visible when mouse is down and invisible when mouse is up, and still follow the spaceship around? I was going to resort to a separate sprite (one spaceship with thrust and one without), but wondered if it could be done in events by instantiating the object
Thanks in advance
Develop games in your browser. Powerful, performant & highly capable.
Is your afterburner object a sprite? If so, just do something like
-->Is mouse down, afterburner opacity<100-------set opacity to Self.Opacity+300*dt
-->Else, afterburner opacity >0-------set opacity to Self.Opacity-300*dt
That will make it fade in and out where 300 is the speed. If your object is a particle object, just set the firing rate to something when the mouse is down and 0 when it isn't. I wouldn't recommend creating and destroying your afterburner object every time you click, though.
Add the System Condition "Trigger once while true" to the end of the event where you spawn the particle system. It must be the last condition in the event.
Mouse is down && Trigger once while true -> visible
Mouse is down (inverted) && trigger once while true -> invisible
Alternatively use the onMouse pressed and released events, they only trigger once.
I did this before actually
On Start of Layout Pin the Burner to the ship.
Preset the burner invisable.
On Left Mouse button down >> Set Burner Visable
Invert On Left Mouse button down >> Set burner Invisable.
Yes leaving it invisible and simply turning it visible while Mouse is down will be the easiest. And you can set it to play a animation while visible for more flare. Dont worry about spawning then destroying the sprite. That actually makes more load on your game then simply toggling the visibility.