View Full Version : Get Attributes of Sprites

23 May 2013, 4:56 AM
I have a Draw Component to which I can add different Sprites. Now I want to implement something like a "zoom"-function, so I have to alter the position, the width and the height of every single Sprite.
It is no problem to set an absolute value to each of the sprites like that:

function zoomIn() {
to : {
width : 200,
height: 200,
x: 500,
y: 500

But for that zoom-Function, I have to set these values relative to the current values; but there is no method for that in CompositeSprite. Even when I iterate over the Sprites via "each", there is in the class Sprites no method for getting the attributes.
So I need something like:

mainDrawArea.surface.getGroup('sprites').each(function (item, index, len) {
width : this.getAttribute('width') + 100,
height : this.getAttribute('height') + 100,
x: this.getAttribute('x') + 100,
y: this.getAttribute('y') + 100
}, true);

Is this possible?

28 May 2013, 9:35 AM
There is a feature request in our internal tracker for this request.
In the meantime you might inspect the sprite in your console. I believe there's an 'attr' property that might help you (though it's undocumented and thus a risky property to rely on - it could change / go away in future releases without warning).