I am currently working on an abstract rendering system, that provides an easier api to draw-calls.
When I create a new instance of the renderer, I pass the matrix-instance of the current sprite.
In following code - which is in the game loop - the rectangle moves to the bottom, as you would expect it:
graphics.translate(0,100);
graphics.beginFill(0x526516);
graphics.drawRect(0,0,100,100);
graphics.endFill();
However, if I undo the transformation right after drawing the rectangle, the rectangle won’t translate at all. You would expect it to stay at y=100.
graphics.translate(0,100);
graphics.beginFill(0x526516);
graphics.drawRect(0,0,100,100);
graphics.endFill();
graphics.translate(0,-100);
Does somebody have an explanation for this?
Thanks in advanced!