Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Crafty.attr({}) function? #1205

Open
0xf0xx0 opened this issue Dec 22, 2018 · 3 comments
Open

[Enhancement] Crafty.attr({}) function? #1205

0xf0xx0 opened this issue Dec 22, 2018 · 3 comments

Comments

@0xf0xx0
Copy link

0xf0xx0 commented Dec 22, 2018

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?

@starwed
Copy link
Member

starwed commented Dec 24, 2018

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.)

@0xf0xx0
Copy link
Author

0xf0xx0 commented Dec 25, 2018

Huh, i did not know that. I see your point as the general setter, is it possible to "compact" it?

@0xf0xx0
Copy link
Author

0xf0xx0 commented Dec 25, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants