Open NickPax opened 6 years ago
I don't understand. Your example still has a box variable.
Hi Josh, all I meant was that you don't need this line: const box = $("#box")
True, you could write it as
on($(‘#box”),’clicked’,() => $(#box).components.blah)
However I prefer to use an explicit variable to make it easier for people to understand. In practice I would do the shortened version in my own code, but I’ve found one line arrow functions to be tricky for newbies to understand.
Even this works: on(box,'click', () => box.components.sound.playSound())
Which is nice because there's less actual code, but I see what you're saying.
Don't need to make a box var, as the 'el' parameter picks up the entity. So this works ok: on(box,'click', () => box.components.sound.playSound())