views:

36

answers:

2
I have a sprite inside another sprite
SpriteB is inside SpriteA
I would like to change the default coordinate(top left corner) to say 250,10
When SpriteB.x = 0, SpriteB.y = 0 puts SpriteB to 250,10 in SpriteA
Is this possible?
A: 

You should be able to use the transform.matrix property of the sprite:

SpriteB.transform.matrix = new Matrix(1, 0, 0, 1, 250, 10);
Michael Brewer-Davis
+2  A: 

any child is referenced by the coordinate system of the parent, therefore if spriteB is contained in SpriteA, the x and y of SpriteA are added to that of spriteB when position is worked out.

all you have to do is SpriteB.x=250; SpriteB.y=10; and it will work.

shortstick
just to clarify, that code would go in SpriteA, NOT in SpriteB, and you would have to replace SpriteB with the actual instance name of your SpriteB instance.
jonathanasdf