-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
When does a Sprite's width and height become valid? #35
Comments
Ah yes! This is because the image for the texture has not loaded so it has no idea what its width and height is :/ The way I have been solving this is by using the assetLoader to preload my images. That way the width and height is always set correctly when I create my textures like this:
Another way would be to add an eventlistener to your texture. When the image has loaded it dispatch an 'update' event.
Hope that helps :) |
Its also possible to do such thing : #29 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
When I load a texture into a sprite, and then ask for the sprite's width, I get a value of 1. Only after going through the animation loop a couple times does the width become valid. Is there a reliable way to check the dimensions of a loaded texture?
All of those
console.log()
s log "1, 1" even though it should be 128, 128. If I put thatconsole.log()
in the animation loop, it does start to output 128, 128.The text was updated successfully, but these errors were encountered: