How to change the width ONLY 1 SIDE?

ChakkuChakku Member Posts: 1,513
How do you change the width on only 1 side.

https://www.dropbox.com/s/lxhzmok5all526u/Example.gameproj.zip

Notice how it's increasing in size on BOTH going up AND down. How to make it only increase going one way?

I think its and easy question.

Can anyone help?

Thanks


https://www.dropbox.com/s/lxhzmok5all526u/Example.gameproj.zip

Best Answers

  • gyroscopegyroscope I am here.Posts: 6,598
    edited December 2012 Accepted Answer

    Hi @Chakku
    @MSEagle2 But how to specify whether to grow on the left or right (in my case up or down).
    If growing to the left or right, this will alter the x coordinate; in your case, up or down , will effect the y coordinate. These need to be half the growth rate of the changing side, exactly as @MSEagle2 mentioned.

    So based on Rule you have, add a change y position too (exactly half the growth rate):

    Timer Every 0.04 seconds
    Change Attribute self.Size.Height to self.Size.Height+2
    Change Attribute self.Position.Y to self.Position.Y+1

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • CodeMonkeyCodeMonkey Posts: 1,803
    Accepted Answer
    An actor's position is always in the center of that actor. If the width changes, you'll see that it increases in 2 directions.

    What you would need to do is store its current position and the width before changing the width of the actor, then as you increase the width, you would either need to add or subtract half of the change in width for it to appear to increase in one direction or the other.

Answers

  • MSEagle2MSEagle2 Member, PRO Posts: 98
    move the object by 1/2 of the increase in width to keep it stationary. So if you are increasing width by 10, move it 5 to the right so that it only expands on the right side
  • ChakkuChakku Member Posts: 1,513
    @MSEagle2 But how to specify whether to grow on the left or right (in my case up or down).

    Please download the example file I uploaded to see what I mean

    Thanks for the response.
  • ChakkuChakku Member Posts: 1,513
    @gyroscope @CodeMonkey

    Thanks it worked!
Sign In or Register to comment.