Actor anchor question

RohalRohal GermanyMember Posts: 62

If i place an actor on screen the x and y pos define the center of the actor.
I thought the params "horizontal anchor" and "vertical anchor" which are set to "left / bottom" by default should place the actor by it's upper left coords.
Or do i understand this wrong?

Thanks in advance.
Rohal.

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    @Rohal said:
    If i place an actor on screen the x and y pos define the center of the actor.

    Yep !

    I thought the params "horizontal anchor" and "vertical anchor" which are set to "left / bottom" by default should place the actor by it's upper left coords.

    Nope !

    Those parameters appear under 'Graphics' and apply to the graphics on the actor rather than the actor itself.

    Also - generally speaking - "left / bottom" refers to lower left - rather than "upper left" (bottom = lower).

    But it's easy enough to 'anchor' an actor wherever you like (depending on what you are trying to achieve).

  • RohalRohal GermanyMember Posts: 62

    Background of the question is that i have a spawner which spawns different actors with different sizes.
    All random actors should be placed on the ground (y=100).
    Because of the different sizes and the fact that the spawned actors are set by their center/center position, they are not placed on the ground.
    I have to adjust the y position for every actor.

    It would be easier if i could they that bottom/left for example is the anchor for placement.
    Do you understand what i mean.

    Any ideas to get this solved without adjusting pos y for every spawned actor?

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2014

    @Rohal said:
    It would be easier if i could they that bottom/left for example is the anchor for placement.
    Do you understand what i mean.

    The maths is simple enough, position the actor at half its height above the floor.

  • RohalRohal GermanyMember Posts: 62

    @Socks‌
    Thanks. Sometimes it could be so easy... ;-)

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2014

    @Rohal said:
    Socks‌
    Thanks. Sometimes it could be so easy... ;-)

    I don't know what you are using to randomise the actor's size, but place this after you have changed the size.

    Change attribute : self.position.Y to 100+(self.size.Y / 2)

  • RohalRohal GermanyMember Posts: 62

    The actors size isn't randomized. There are a few background images which are spawned randomly. Every background actor has a different size.

Sign In or Register to comment.