substract 25% of original sprite size

0 favourites
  • 9 posts
From the Asset Store
25 high-quality robots. This asset is perfect for a side scrolling game, or even a turn based RPG type game.
  • 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:)

  • 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 method

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Haha, it's clever to use an absolute number. <img src="smileys/smiley20.gif" border="0" align="middle" /> SecondDimension

  • cvp

    SecondDimension

    ok guys creating variable is good solution but how create extension 'substract percent' ?

  • 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?

  • cvp YES :)

  • delgado YEEY <img src="smileys/smiley4.gif" border="0" align="middle" />

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)