Welcome to the Treehouse Community
Looking to learn something new?
Why is the syntax for function addItems and function addPlatforms different when they are both doing the same thing?
[Contd.] Which is adding graphics to the game? (to add a coin, we are using createItem, and to add platform we are using platform.create) Is it because to add a coin we are using a different function as it is a collectable item which has to disappear when collected?
createItem contains similar snytax
var item = items.create(left, top, image);
but also includes code to add the spin animation to coin
item.animations.add('spin'); item.animations.play('spin', 10, true);
Yes. It looks like animations are set individually and the function is used to avoid repeating three lines of code for each item. Whereas after creation the platforms use a setAll method to fix the position of all platforms.
For fun comment out the following and see what happens