Ask coding questions

← Back to all posts
KaboomJS Program Not Loading Sprites
h
UCYT5040 (14)

I am using a template from the KaboomJS docs, however none of the sprites are loading. How can I fix this?

Answered by Coder100 (17088) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (17088)

you DON'T import them.
This is the kaboom language so that's handled for you on run.

UCYT5040 (14)

@Coder100 Thanks! Do you know why I get this? TypeError: player.move is not a function at Object.init (/:68:8) at go (https://kaboomjs.com/lib/master/kaboom.js:1570:9) at frame (https://kaboomjs.com/lib/master/kaboom.js:2009:5)

Coder100 (17088)

@UCYT5040 yeah you have an extra )

please fix your code first

const player = add([
    // a 'sprite' component gives it the render ability
    sprite('froggy'),
    // a 'pos'component gives it a position
    pos(100, 100),
    // a 'body'component makes it fall and gives it jump()
    body(),
    // raw strings are tags
    "player",
]);