substract 25% of original sprite size

Get help using Construct 2

Post » Wed Jul 31, 2013 10:15 am

or substract from width and height -25% every collision
i need two options:
First when colision object fromm 100% size substract 25% = 75%
but when collision is second time we have 50% right?

Second option if we have original 100% size for example 100x100px and colision is detected substract 25% (25px) but if sprite have now 75x75px and again colision have detected we substract 25% not 25 px:)
B
107
S
25
G
43
Posts: 1,882
Reputation: 33,501

Post » Wed Jul 31, 2013 1:15 pm

I think you could do it with an instance variable. So set up a variable called var_Scale, set it to 1 to start with. When there is a collision you say:
> Subtract 0.25 from var_Scale
> Set Scale of Sprite to 1
> Set Scale of Sprite to (var_Scale)

That way each collision should reduce by 25% of the original size right?

Edit: I tested and this worked, although there might be a more elegant methodSecondDimension2013-07-31 13:20:40
B
15
S
5
Posts: 141
Reputation: 1,657

Post » Wed Jul 31, 2013 1:18 pm

If you want to shrink the sprite by 25% at each collision you could just multiply the with and height with 0.75 at each collision

If you want it to shrink a % of the original size, then just store the original size in a instance variable. Then multiply the original size with 0.75 and subtract that from the current width and height.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Wed Jul 31, 2013 1:28 pm

Haha, it's clever to use an absolute number. @SecondDimension
B
37
S
4
G
2
Posts: 45
Reputation: 3,997

Post » Wed Jul 31, 2013 5:42 pm

@cvp
@SecondDimension

ok guys creating variable is good solution but how create extension 'substract percent' ?
B
107
S
25
G
43
Posts: 1,882
Reputation: 33,501

Post » Wed Jul 31, 2013 6:31 pm

I am not totally sure i know what you mean about "create extension"

I have made a small example of how it could be done.

.capx

Everytime you drag one of the balls into another ball both of the balls will shrink 25% in size.

its a function call. So if you want it to be something else just alter the parameter going in to the function.

Was that what you were looking for?
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Wed Jul 31, 2013 6:45 pm

@cvp YES :)
B
107
S
25
G
43
Posts: 1,882
Reputation: 33,501

Post » Wed Jul 31, 2013 6:51 pm

@Delgado YEEY
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Wed Jul 31, 2013 6:54 pm

I used a solution very similar to CVP's for my Orbital Bomb-Bounder game, it stored the original size, and 'every 10 seconds' if below the original size it would grow one hit back. (so each bullet hit shrunk it, and after time it restored itself.)

I also used 'max(Size,MinimumSize)' in the size setting, so it wouldn't shrink past a certain point.
B
226
S
60
G
32
Posts: 902
Reputation: 39,438


Return to How do I....?

Who is online

Users browsing this forum: SoldjahBoy and 9 guests