FAQ: Learn Phaser: Basics - Move Your Bodies

#1

This community-built FAQ covers the “Move Your Bodies” exercise from the lesson “Learn Phaser: Basics”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Phaser

FAQs on the exercise Move Your Bodies

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

#2

Hi,

On slide 7 (update slide), when I add the circle global variable (let circle;) and create() my circle. Codey disappears. Why is this? chin scratch

Any info would be greatly appreciated

-Gage

#3

Code O_o

let codey;

function preload() {
this.load.image(‘codey’, ‘https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png’);
}

function create() {
codey = this.add.sprite(0, 100, ‘codey’)
}

function update(){
codey.x += 1;
}// Create your update() function here

let circle;

function create(){
circle = this.add.circle(0,100,20,0xff0000);
}

function update(){
circle.x += 1;
circle.y += 1;
}
const config = {
type: Phaser.AUTO,
width: 400,
height: 400,
backgroundColor: “#000000”,
scene: {
preload,
create,
update,
// Include update here!
}
}

const game = new Phaser.Game(config)

#4

I think this is because you have 2 update functions. Programming languages don’t like this in general.

Try combining these 2 functions and let me know if that works.

The same happens for the function create() i just noticed. You have 2 of those as well.

In general there can’t be 2 or more function of the same name inside a project.

#5

Got it, it was because I had two create functions. Wrote both objects under the same create function and got visibility and movement on both.

Thanks for your response :grin:

#6

Why phraser.js is so typical. It is tougher than learning javascript