danzen / zimjs

ZIM JavaScript Canvas Framework - Code Creativity! Interactive Media For All.
Other
508 stars 47 forks source link

Spritesheet animation question #10

Closed wiggleMyEars closed 7 years ago

wiggleMyEars commented 7 years ago

Dear Dan,

Thank you for making this incredible library and its excellent documentation!

I think I'm getting something wrong here... zim_4.1.1.js seems to run the spritesheet animation without any problems, but zim_5.2.2 seems to have problem finding the canvas, it throws up a getContext error. I am sure this is my lack of experience with js.

Thank you for this wonderful resource!

Jim

danzen commented 7 years ago

Hi Jim - sorry for the delay getting back - just noticed this. Assuming you have a CreateJS SpriteSheet and were passing that in as a the first parameter to the ZIM Sprite(). You should be able to fix this as follows:

new zim.Sprite({spriteSheet:spriteSheet});

As of 4.7.0 there was a change to the Sprite to make the CreateJS SpriteSheet internally. So the Sprite() parameters have changed. The Documentation has an "updates" link http://zimjs.com/code/updates.html which has the following under 4.7.0:

Sprite has json parameter which replaces spriteSheet parameter BREAK The SpriteSheet is now made internally from the json can still pass in rows and cols as well instead of json Note that the BREAK - means old code might break. Then in 5.2.0 we added the spriteSheet parameter back in (in a different place at the very end) as CreateJS came out with dynamic SpriteSheet building with SpriteSheetBuilder!

So, sorry for the run around - I hope that is the issue - just check the recent Sprite() parameters in the docs at http://zimjs.com/code/docs.html?id=sprite Note that you may not need to make the CreateJS SpriteSheet as you can now just pass in the JSON information for that SpriteSheet and the ZIM Sprite will make the SpriteSheet for you ;-). See the http://zimjs.com/code/spritesheet example. I will update the ZIM Bits that have older SpriteSheet examples...

danzen commented 7 years ago

I have updated the two ZIM Bits that dealt with Sprites to the new way ;-) http://zimjs.com/code/bits/view/scrub.html http://zimjs.com/code/bits/view/explosion.html Thanks, Jim, for using ZIM - all the best... let me know if that works for you.

wiggleMyEars commented 7 years ago

Thank you Dan! Works a treat. I knew it would be something I'd missed. Sorry to have bothered you when it was in the updates documentation. Thank you for your help and for a wonderful resource Jim

danzen commented 7 years ago

Hi Jim - not sure how to reach you - but come on in the ZIM Slack Group if you want - here is an invite https://join.slack.com/t/zimjs/shared_invite/MjMwNDM0MDkzOTg1LTE1MDM1NDIxNDktNGRlMzBjMjRiYQ

Not sure if you have been keeping up with ZIM – but lots of updates over the summer – see the 30 or so Bubbling videos and there is a new site – we are on ZIM Six now!

Dan