Looking to increase the size of an actor (on collison) by a set number of pixels, not percentage.
Hi all,
I'm hoping you can help me, I've been trying to create a specific rule in GameSalad. I've searched the forums but couldn't find an answer.
Here's what I'm looking for:
I have an actor that I want to change the size of when it collides with an object.
For example, when the actor collides with a red object, the actor decreases in size by 25 pixels width and 25 pixels height.
Similarly, when it touches or collides with a green object, the actor increases in size by 25 pixels width and 25 pixels height.
To give an example: If my actor is 25x25 pixels, and it collides with 2 green objects, it grows to 75x75 pixels, then if it collides with 1 red object it shrinks to 50x50, if it collides with 2 more green it will grow to 100x100 pixels
I'd love to know what the solution is, any help is much appreciated
Thanks in advance!
Matt
Comments
Rule
--When actor collides with red object
----Change width to width-25
----Change height to height-25
Rule
--When actor collides with green object
----Change width to width+25
----Change height to height+25
You might also want to add in a condition that prevents your actor going to 0 (unless that's what you want to happen).
So . . .
Rule
--When actor collides with red object
----And . . . When self.width is more than 25
------Change width to width-25
------Change height to height-25
Hi Socks, many thanks for your answer! Really appreciated
Unfortunately, it does seem to change the size of the actor but if I use +25, it changes the actor to 25 pixels in size rather than increasing the size of the actor by 25 pixels.
The rule I'm using is:
'When Actor receives even - overlaps or collides - with actor of type - green object
Change attribute: self.Size.Width - To: +25
Can you suggest anything else?
It needs to be:
Change attribute: self.Size.Width - To: self.Size.Width+25
Mental Donkey Games
Website - Facebook - Twitter
Try the suggestion I posted above, it does work.
Rule
--When actor collides with red object
----Change width to width-25
----Change height to height-25
Rule
--When actor collides with green object
----Change width to width+25
----Change height to height+25
. . . . . . . .
So, if the width is - for example - 200, and you run the rule that states: Change width to width+25, then you are effectively saying: Change 200 to 200+25.