Crafty
Crafty copied to clipboard
[Enhancement] Crafty.attr({}) function?
To be honest, using the .attr
property(?) is sorta annoying to use. Why not have it a function? It only takes up to 4 integers, so I think using it as .attr(x, y, w, h)
would be much easier to use. Example:
var player = Crafty.e('2D, Canvas, Color, Fourway, Collision')
.attr(200, 200, 10, 10)
// Other properties...
And then calling any additional properties as:
.props({
currHealth: 100
maxHealth: 100
// Other custom properties...
})
Would this work, or no?
Having a separate method for setting x/y/w/h in one swoop would be reasonable, but I think attr
should remain the general purpose setter.
(There's already an internal method called _setPosition
that sets the x/y properties; something similar could be done for all four.)
Huh, i did not know that. I see your point as the general setter, is it possible to "compact" it?
Also, quick question. Where are the docs for the .clone()
method? I cant find them anywhere. Crafty.e
refers to Crafty.c
, which refers back to .e
.