Ask coding questions

← Back to all posts
Why are my sprites not showing up ingame?
h
xMisbahx (20)

I am making a game(trying). I handmade all of the sprites, including the duck,the frog, evil frog, background and portal. The duck,frogs, and portal are not showing up even if I add them, and there are no errors saying that the code is wrong.
why are they not showing up?

p.s., even though it says I used JS, I used Kaboom.js

Answered by Geocube101 (645) [earned 5 cycles]
View Answer
Comments
hotnewtop
Geocube101 (645)

Try adding sprites/ to the front of your paths in the laodSprite function

Right now, your paths are searching for the sprite name inside of the main directory, but main is located inside of sprites

Example:

loadSprite("froggyminion", "main/froggyminion.png")
script.js
main
 │
 └ froggyminion.png

..needs to be...

loadSprite("froggyminion", "sprites/main/froggyminion.png")
script.js
sprites
  │
  └ main
     │
     └ froggyminion.png

I'm not sure if kaboom automatically detects for the sprites folder so this may not work

xMisbahx (20)

@Geocube101 the way that kaboom works is that I have a line called loadRoot("/sprites/"), which is the folder where all of my sprites are located, so it is automatically adds sprites/.

Do you think something is wrong with the sprites? The background still works when I add it but...

Geocube101 (645)

@xMisbahx did a little research (not much) but why are you creating a sprite animation for your sprites. The images you have aren't in an atlas for animations.
Example of texture atlas for animations
So far I got it to display by removing the animation declaration from the loadSprite function (basically everything in the curly brackets) and changing the scale back down to 1.
Kaboom seems to expand the sprite from the top left corner, and as your image has a lot of whitespace around it, at large scales it disappears completely.

xMisbahx (20)

@Geocube101 it worked! THANK YOU SO MUCH. you get stars for effort: ***