Is it possible to return the current x y position of a sprite?
Also is there a "center" sprite function?
Many Thanks
MrSparks
Printable View
Is it possible to return the current x y position of a sprite?
Also is there a "center" sprite function?
Many Thanks
MrSparks
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");
or alternatively
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
console.log(sprite.attr);