Transforming

Get help using Construct 2

Post » Tue Jan 29, 2013 6:05 am

How do I transform a sprite while playing? For example when Mario gets a fire flower he turns into Fire Mario and can now shoot fireballs. Carbon642013-01-29 20:10:07
B
18
S
5
G
4
Posts: 63
Reputation: 3,912

Post » Tue Jan 29, 2013 10:00 am

@Carbon64
Short version:
You can use sprite's animations and variable.
Edit your sprite, add another animation (with some Fire Mario frames).
In event sheet, when transform is on, set your sprite's animation to the good one. Then set a sprite's variable to 1 if needed to detect the transform.
If press fire button and this variable is 1 ==> launch fireball !
B
31
S
9
G
1
Posts: 45
Reputation: 4,492

Post » Tue Jan 29, 2013 8:09 pm

Thanks. Now what if I wanted the transformation to last a limited amount of time?
B
18
S
5
G
4
Posts: 63
Reputation: 3,912

Post » Wed Jan 30, 2013 10:30 am

@Carbon64

I'm not sure it's the best method but you can do a thing like this:

Add a global variable (called "timer" for example).
Add en event: Every tick and transform variable = 1, add value dt (not set!) to "timer". Why ? Because sum of dt = 1 every second (deltatime tuto).
So if you want to stop transformation after X seconds, check every tick if "timer" >= X. If true, set transform variable to 0.

or maybe this, better and simpler but dunno if it works:

when transform variable is set to 1, add two other actions : wait X seconds, and set transform to 0.

edit:
it works ! find here a very simple example:
.capx
T to transform, Space bar to fire.PaulPoy2013-01-30 12:25:47
B
31
S
9
G
1
Posts: 45
Reputation: 4,492


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Calfuso and 22 guests