FAQ: Learn Phaser: Basics - Draw A Sprite

This community-built FAQ covers the “Draw A Sprite” 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 Draw A Sprite

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!

Hi

I’m really interested in game making with Phaser but I have an issue.
Whenever I try linking my own image to the script, the only sprite I get is a black box with a green line inside it, this is the code I’ve written.

function preload() {
  // Load in the sprite here!
this.load.image('player', 'http://www.doolwind.com/blog/wp-content/uploads/2015/08/run.png');
}

function create() {
  // Create a sprite game object here!
this.add.sprite(60, 80, 'player');
}

const config = {
	type: Phaser.AUTO,
	width: 450,
	height: 600,
	backgroundColor: "#5f2a55",
	scene: {
    create,
    preload
	}
}

const game = new Phaser.Game(config)

And then I get this

3 Likes

Codey is blocked by CORS!

I am unable to load the codey image from the s3 bucket.

This is the error:

Access to XMLHttpRequest at 'https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png' from origin 'https://abfe70ab988d4a7e9029d30a9d7c912d.cc-propeller.cloud' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Do I need prior knowledge of JavaScript for this course?

I have the exact same problem but with the images in the learn game development with phaser.js classes, i dont know what im doing wrong and it looks like even the solutions from the website are broken since its the exact same thing i did and its still broken.

I got the same problem

wen i type in the page i tells me to go, a can’t find that page it tells me page not found or 404