-
Notifications
You must be signed in to change notification settings - Fork 75
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
add fillRect and fillStyle to sprites (& sprite lists, tile maps) #37
Comments
I don't think there's nothing stopping you from doing that right now? sprite.setImage( ) can take an image or canvas which you have loaded or dynamically created. Maybe I'm missing some finer details of your suggesion? |
could a canvas be used at sprite creation? Should work the same as sprite.setImage()? For example trying to alter example 12 (replacing grass.png) I am getting "Uncaught Error: INVALID_STATE_ERR: DOM Exception 11" in sprite.js line 272:
|
try "return canvas.context" instead of "return canvas" .. does it work? It should. But we could also patch setImage to detect a canvas and do that automatically for us, should be supersimple |
if I do that it looks like it's getting hung up looking for and trying to create an asset: Uncaught TypeError: Cannot read property '1' of null assets.js:66 |
ok, I got confused. It should be an canvas, not a context. So your first example should work. Look at example11.html ... jaws.gfx.retroScaleImage() returns a canvas. Which I one line later send into a Sprite() constructor. |
https://github.com/ippa/jaws/blob/master/src/gfx.js#L13 <-- retroScaleImage() https://github.com/ippa/jaws/blob/master/examples/example11.html#L32-33 <-- jaws.Sprite() using a canvas |
was it really work now? |
not sure what you mean kxh? |
I do it like this new jaws.Sprite({ |
I was thinking it might be useful to be able to create sprites using fillRect and fillStyle as per the canvas 2D context spec, for quick colored background, blocks etc. This could have been used in example 8 instead of block.bmp
Long term creation of sprites using other drawing methods like beginPath & arc could also be cool.
Thoughts?
The text was updated successfully, but these errors were encountered: