Phaser: Create an Adventure

https://www.codecademy.com/courses/learn-phaser/projects/learn-phaser-create-an-adventure

I’m honestly not sure if I’m doing everything right. I feel like I’ve followed all the directions properly up to step 9, but I’m not noticing any changes in the size of the knight. Did I miss something or is it not meant to be a huge, noticeable change in size?

function create() {
 gameState.background = this.add.image(0, 0, 'bg');
 gameState.background.setOrigin(0, 0);
 renderCharacter(this, 'knight');
}

function renderCharacter(scene, key) {
 if (gameState.character) {
   gameState.character.destroy();
 }
 gameState.charcter = scene.add.image(270, 340, key);
 gameState.character.setOrigin(.5, 1);
 gameState.character.setScale(.7);
}

The change of scale is pretty big. It definitely should be noticeable.

Problem is in the typo, take a look at this part of the code:

gameState.charcter = scene.add.image(270, 340, key);
gameState.character.setOrigin(.5, 1);
gameState.character.setScale(.7);

Here you added a new image to the scene and you have assigned this image object to the property charcter of the gameState object. In the two next lines of code you are performing modification on object stored in the character property of the gameState object.

charcter is not the same as character, right? So when you used setOrigin and setScale methods they were executed on an object that was never added to the scene, this is why it seemed like nothing was changed :slight_smile:

2 Likes

well, look at that. read over it several times and never saw that typo. thanks :blush:

2 Likes

You’re very welcome :panda_face: