Sprite not appearing

Link to the project or level: Link to game
What I expect to happen: When the sprite is on the first screen and its x position is greater than 200, the screen should change to the castle with the sprite appearing on top of the castle and with no sprite and the previous screen background.
What actually happens: When the sprite is greater than 200 it changes to the castle, however, the sprite doesn’t appear in front of the castle and the previous screen background doesn’t disappear.
What I’ve tried: Nothing much.

I have kept the castle small for you to see the problem.

So I need to have the castle in the background and a sprite in front of the castle when the previous sprite goes more than 200 and as well the previous screen background goes away and the sprite goes away.

1 Like

It looks like you have changed some of the code since you submitted this.

Maybe a few tips would help.
In GameLab the overall sequence is usually
1.)Declare variables and Sprites
2.)Then anything you want to run/change/check should be inside the draw loop which will loop over and over again. In general most of the code will be inside the draw loop and checked each time through.
3.) Within the Draw loop Backgrounds first, any actions to check, sprite movement or other actions, then draw sprites is usually at the end of the draw loop where you have it. That way, after changes inside the loop are made all sprites are drawn (unless set to not be visible)

When I looked at this link, inside the draw loop “scene” was being checked (does it = 0,1 or 2) When scene0 is clicked it changes to scene1. Then the draw loop continues to check over and over and scene continues to =1
There was no code in the draw loop that would make the scene change, so is only showing scene0, until clicked then the other background is shown, because that happens in scene0 function. The castle is no longer showing up at all.

Perhaps looking at some lessons in Unit 3 would help to clarify some of this for you. Unit 3 Games and Animations

Or here is are more ideas for Game Lab. Learning in Code.org

1 Like

@tim,

Looking at it this morning, I can see that the scene does change to 2 and the castle appears. If it were full size, it would cover up the L1 sprite (background). The Robot sprite does disappear though, due to code both in lines 57 & 64.

Your question mentioned both having “a sprite in front of the castle” (which one?) and “the sprite goes away” (which one?)

Let us know if there is still something not working, but it looks like it is behaving as I would expect it to at this point.

Mike

1 Like