How do I set scale to object scale

Get help using Construct 2

Post » Mon Dec 28, 2015 1:30 pm

When sprite1 is changing scale from 0.1 to infinity and bullet hit sprite1, this sprite spawn another object explosion but explosion should be in this same scale as sprite1

So if sprite1 (scale 0.1) is far away, explosion is small but if its closer (scale more than 0.1) explosion animation is bigger
B
111
S
28
G
48
Posts: 1,882
Reputation: 36,426

Post » Mon Dec 28, 2015 4:35 pm

You will need an instance variable in the sprite1 for CurrentSize=0, then set this variable to the scale of sprite1 when it is hit.
Then all you need to do in your explosion spawn event is set the explosion size to CurrentSize... but make sure you haven't destroyed Sprite1 since your using an instance variable... just make sprite1 invisible while explosion happens and then destroy both sprite1 and explosion at same time... or use a global variable.. but if you have lots of sprite1-# you would need as many global variables if two would ever be destroyed at one time...
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
69
S
18
G
8
Posts: 639
Reputation: 9,549

Post » Mon Dec 28, 2015 5:16 pm

Set the scale of Explosion to Sprite1.Height/Sprite1.ImageHeight. This gives you the current scale of Sprite1.
ImageImageImage
B
71
S
22
G
247
Posts: 3,756
Reputation: 137,558

Post » Tue Dec 29, 2015 12:18 am

@chrisinfinger
@blackhornet
yes i do that before i set to sprite1 variable called 'size' and i pin this in events to always set scale to sprite1.size
but if on screen i hit Sprite1 with scale 5 i receive 5x biggest explosion but if animation is not finished and i hit small sprite1, this big explosion will turned to this small size sprite1 and thats the problem
B
111
S
28
G
48
Posts: 1,882
Reputation: 36,426

Post » Tue Dec 29, 2015 5:30 am

Your saying if one instance is large and explodes and another smaller instance is hit and explodes then the first instances explosion is set to the scale of the latter?
This sounds like a "picking" issue.

Make sure you condition out old sprite1 that are already exploding...

maybe use an instance variable isExploding=0 then set to isExploding=1 at start of exploding animation, then use isExploding=0 to condition out old ones when creating new explosions...
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
69
S
18
G
8
Posts: 639
Reputation: 9,549


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo and 8 guests