cykod / Quintus

HTML5 Game Engine
http://html5quintus.com
GNU General Public License v2.0
1.41k stars 401 forks source link

Fix for Q.Sprite.center() #107

Closed mpkorstanje closed 10 years ago

mpkorstanje commented 10 years ago

When centring a sprite inside a container, the x,y coordinates should be set in sprite coordinates (0,0) rather then those of parent (p.w/2,p.h/2).

For a quick test run:

Q.scene('test',function(stage) {
    var one = stage.insert(new Q.Sprite({x:100, y:100, color:'red',w:200,h:200}));
    var two = stage.insert(new Q.Sprite({color:'blue',w:100,h:100}),one);
    two.center();
});
Q.stageScene('test');

As is right now turning two.center(); off will result in the correct behaviour.