Skip to content
Changing the sprite of an object in kaboom.js
Profile icon
SixBeeps

I have an object

var nark = add([ sprite("spr_1") ]);

How might I change the sprite to something different programatically? Ive tried both of these, but to no avail:

nark.sprite = sprite("spr_2"); nark.sprite = "spr_2";
You are viewing a single comment. View All
Profile icon
Bookie0

Not sure, but perhaps load the sprite 2, then you can change it using the methods you've used above?

Also, according to H's tutorial here:

Note that this tutorial was made while Kaboom.js was in beta so don't be surprised if the code doesn't work for you.

And you probably have already, but maybe try the documentation here? I tried checking if there was anything about changing sprites, but unfortunately didn't find anything.

Good luck! :D

Profile icon
SixBeeps

@Bookie0
Kaboom auto-loads sprites, so the above methods still don't work. Documentation doesn't say anything, that's why I'm here :)

Thanks though.

Profile icon
Bookie0

@SixBeeps
Ahh okay then, np.

Hope you find it