jvinhit

Members
  • Content Count

    9
  • Joined

  • Last visited


Reputation Activity

  1. Like
    jvinhit reacted to lewster32 in Child position relative to parent anchor strangeness 2   
    The reason this is happening is because each object is using its own anchor; anchors are not relative in this situation. As soon as you start to scale objects, they will behave as if they are independent (because from the renderer's point of view, they are) and each will scale around its anchor point - and the problem is that I assume you're expecting the anchor points themselves (i.e. the positions of the objects) to also scale with your player, but this is not the case (see attachment) unless you actually use addChild or similar to make it a child of the object you're scaling - but then you run into the ugly text scaling issues which I assume is what you're trying to avoid.
     
    What you need to do is use getBounds on the object you're scaling, and then set the x and y positions of the objects you want to move with the scale according to its bounds. See this fiddle for an example:
     
    http://jsfiddle.net/lewster32/Kc4N2/
     
    In the fiddle, in the update function I reposition the text accordingly, with the number centered on the object, and the name centered on the object's bottom bound. You will need to replicate this inside your extended sprite but the theory still holds true.

  2. Like
    jvinhit got a reaction from jdnichollsc in Making a scrolling list.   
    thanks !