Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by FelipeBudinich

It's just a small improvement, but I was on the brink of madness while developing my GUI/HUD and then I realized that I could use both Z_INDEX and POS_Y together to place those elements on top of everything.

(by the way, I wasn't able to inject this, anyone knows how?)

ig.Game.SORT = {
	Z_INDEX: function( a, b ){ return a.zIndex - b.zIndex; },
	POS_X: function( a, b ){ return a.pos.x - b.pos.x; },
	POS_Y: function( a, b ){ return a.pos.y - b.pos.y; },
	// Can't understand how to inject this
	POS_YZ: function( a, b ){ return (a.pos.y - a.zIndex) - (b.pos.y - b.zIndex); }
};

1 decade ago by Philip

You could just write

ig.Game.SORT.POS_YZ = function( a, b ){ return (a.pos.y - a.zIndex) - (b.pos.y - b.zIndex); }

1 decade ago by FelipeBudinich

Quote from Philip
You could just write

##
ig.Game.SORT.POS_YZ = function( a, b ){ return (a.pos.y - a.zIndex) - (b.pos.y - b.zIndex); }
##


Heh, I always forget about the fact that functions are variables in javascript,

Thanks :-)

1 decade ago by Philip

Thats the fun part about it :)
Page 1 of 1
« first « previous next › last »