8 Aug 2011 3:00 AM #1
Ext.Draw - Get Sprite position?
Is it possible to return the current x y position of a sprite?
Also is there a "center" sprite function?
4 Dec 2012 10:38 PM #2
After some search within the source of "Ext.draw.engine.SVG", I found something quite usefull, that might help you and others having the same Issue out.
x = sprite.el.dom.getAttribute("x");
y = sprite.el.dom.getAttribute("y");
x = sprite.el.getAttribute("x");
y = sprite.el.getAttribute("y");
(sprite being an instance of Ext.draw.Sprite)
Those calls will retrieve the current position. Tested with 4.1.1 (available for non-subscribers also)
- edit -
It seems that the return type of those calls is "string". I recommend using "parseInt(value, radix);", to convert the value.
- another edit -
another way to get the current position and other attributes of a sprite I recently "discovered":
x = sprite.attr.x;
y = sprite.attr.y;
just take a look at