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
I'm having a hard time wrapping my head around crafty mechanics. Can I ask for a little explanation? #1193
Comments
Here is fine for now. :) I think there are a few issues with how you've set up the jsbin:
You also define the When I tweaked these, I could see the sprite rendering ok.
Yup, that's just to make it easy to follow the suggestion about adjusting run speed. |
Thanks for responding
So to see that I have it straight: |
It's always optional -- once you've created an entity, Crafty will keep a reference to it internally. For many uses, you can find it later by using the various core Crafty selectors. (e.g. The main reason to assign to a variable is if you want to keep a reference to that specific entity. The alternative is generally to use the events system instead. For instance, imagine you had a projectile that was supposed to home in on an enemy. There are two fairly different ways you could solve this:
I'm not sure one is really better than the other. Using direct references can be a bit simpler conceptually, but binding to events can be more flexible. |
I posted this to the google group, then saw that the group hasn't had activity in "a while" so I pulled it to post here.
To get my first steps with crafty, I figure I'd build a solitaire game. I have a card face spritesheet, and used the JS object method of defining the cards. As a baby step, I just want to show one card (the position is defined as "AceHearts") before I delve into any real logic.
On the Sprites intro http://craftyjs.com/documentation/sprites.html, I KINDA get how the animation is actually called. I see in the
go()
function that a variable is declared, but it's never used, so that's weird to my brain. But I get that the chained functions,.reel
and.animate
, are what's drawing the sprite anim to the screen.Based on the "Static Sprite" section of the above linked page, I don't understand how the single sprite is being called. In the JSBin space there, when I change
var small_sprite
from the animated sprite to the static sprite, it shows the single frame.However, when I do this with my own asset, I get nothing on screen and no errors in console. According to the chrome inspector, all my assets are loading, and there's no errors, but I get nothing.
Is there a better place to post questions like this?
The text was updated successfully, but these errors were encountered: