[TIP] - Auto resize actor properly
Hunnenkoenig
Member Posts: 1,173
I needed something, where my image gets resized only knowing the new height value.
I spawn an actor by another one and I wanted to set the height of the spawned actor according to the size of the spawner actor.
Now I made a game attribute with the height of the spawner (change or constrain) and in the spawned actor I made an old height/old width attribute (integer) with the original values.
Then I used change attribute self.size.height to game.spawner-height
and self.size.width to (old width / old height)*game.spawner-height
With this formula I get my actor resized in the proper way and have no worries about the actor being stretched or so...
Maybe it helps somebody.
I spawn an actor by another one and I wanted to set the height of the spawned actor according to the size of the spawner actor.
Now I made a game attribute with the height of the spawner (change or constrain) and in the spawned actor I made an old height/old width attribute (integer) with the original values.
Then I used change attribute self.size.height to game.spawner-height
and self.size.width to (old width / old height)*game.spawner-height
With this formula I get my actor resized in the proper way and have no worries about the actor being stretched or so...
Maybe it helps somebody.
Comments