How do I scale multiple sprites?

0 favourites
  • 5 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • Is it possible in Construct to scale multiple sprites like this?

    When i try to scale them via actions, they got resized based on their origin point, but i don't need this method. I would like to resize it like whole object. Is it possible to group objects like this and then to scale them down (resize) all together?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you want to do that in the editor you can select the objects, right click on that, and select wrap selection (shortcut key is return I think).

    If you want to do it when running the game you can do this:

    Global number scale=0.5

    Global number centerx=320

    Global number centery=240

    Start of layout

    — sprite: set x to (self.x-centerx)*scale +centerx

    — sprite: set y to (self.y-centery)*scale +centery

    — sprite: set width to self.width*scale

    — sprite: set height to self.height*scale

    That will scale around any center instead of just the object centers.

    To have actual resize handles at runtime is a bit more involved. There is a resize handle example you should be able to find with the search I think.

  • If you want to do that in the editor you can select the objects, right click on that, and select wrap selection (shortcut key is return I think).

    If you want to do it when running the game you can do this:

    Global number scale=0.5

    Global number centerx=320

    Global number centery=240

    Start of layout

    — sprite: set x to (self.x-centerx)*scale +centerx

    — sprite: set y to (self.y-centery)*scale +centery

    — sprite: set width to self.width*scale

    — sprite: set height to self.height*scale

    That will scale around any center instead of just the object centers.

    To have actual resize handles at runtime is a bit more involved. There is a resize handle example you should be able to find with the search I think.

    This code doesn't scale object like in the gif that i posted above. I know about wrap selection, but that can't help me, because i want to resize sprites inside the game, during runtime.

    Your code resizes sprites like this:

    EDIT: I had pin behavior enabled, so resizing was wrong in this gif. When i turn if off during resizing it works perfect. Thanks!

  • Can you tell me what would i have to change in order to enlarge objects back to the previous size?

    Like what you did here, but in reverse.

  • You could reverse it by scaling by 1/scale instead of scale. Or you could store the original position and sizes to instance variables.

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