Shapes doesn't appear in Code.org gamelab?

37 Views Asked by At

I am using code.org's gamelab for my assignment, how ever no matter how I reordered it, the shapes doesn't want to show up.

var bg = createSprite(200, 200);
bg.setAnimation("bg");
var char = createSprite(100, 100);
char.setAnimation("guy3");
var guy = createSprite(300, 270);
guy.setAnimation("guy2");
function draw() {
  char.x = char.x + 50;
  drawSprites();
}
fill("brown");
noStroke();
rect(40, 150, 200, 25);
rect(250, 300, 200, 25);
stroke("black");
fill("white");
textSize(40);
text("yea obv", 15, 250);
text("wow this is good", 20, 50);

This is what I got so far but I can't figure out why it isn't appearing.

1

There are 1 best solutions below

0
On
var bg = createSprite(200, 200);
bg.setAnimation("bg");
var char = createSprite(100, 100);
char.setAnimation("guy3");
var guy = createSprite(300, 270);
guy.setAnimation("guy2");
function draw() {
  char.x = char.x + 50;
  drawSprites();
  fill("brown");
  noStroke();
  rect(40, 150, 200, 25);
  rect(250, 300, 200, 25);
  stroke("black");
  fill("white");
  textSize(40);
  text("yea obv", 15, 250);
  text("wow this is good", 20, 50);
}

This should work. The reasoning is that the shapes appear once (or not at all not sure exactly how function draw() works) with your code. But the background will override it. In order to get around this you need to put the shapes in the draw() so they will be redrawn each time the function executes. If this doesnt work please explain.