Jump to content

getLocalPosition issue when used on a scaled or different width/height Sprite ?


Recommended Posts

Hello !

I'm wondering if this should be reported as an Issue.

So first, my game is at 100%, and the Sprite in question is in two scaled containers (Group) .
let's call that sprite "overlaySprite".

I just want to get the pointer position when it's down on that overlaySprite.
overlaySprite represents a gradient so to fill the screen I've forced its width and height.
the result of this is getLocalPosition(overlaySprite,pointer); in my overlaySprite.events.onInputDown listener returns a point that would be perfect if the overlaySprite was NOT of a different width and height than what it's supposed to be.

So I tried scaling it instead. it would be visually the same, as if I changed width and height of overlaySprite...
But I still get the same problem.

I realised that to fixed that, scaling the point I get from getLocalPosition worked.
I would scale the point's x with overlaySprite.scale.x and the point's y with overlaySprite.scale.y . logically.

but this is a bad solution.
Because I'm using haxe, getLocalPosition wasn't overloaded to allow a Group as first argument so I added this overload.
and now using the parent Group of overlaySprite works fine, sure.

Still I think I should be able to get correct values when using getLocalPosition on a scaled Sprite.

should this be reported as an issue?

Thanks !


Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...