Results 1 to 2 of 2

Thread: Ext.Draw - Get Sprite position?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Ext JS Premium Member
    Join Date
    Jul 2010
    Location
    UK
    Posts
    534
    Vote Rating
    29
      0  

    Default 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?

    Many Thanks
    MrSparks

  2. #2
    Ext JS Premium Member
    Join Date
    Mar 2011
    Location
    Germany
    Posts
    5
    Vote Rating
    29
      0  

    Default possible Solution

    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);

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •