FAQ: Learn Phaser: Basics - Input

#1

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

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

Hello can I please have the hint code for lesson 9 question 3? There isn’t any and I’m stuck

#3

With this, you want to assign rect1 as interactive and fill in the color values as the default, so as you click rect2 you’ll get a switch and clicking rect1 will get you back to the normal colors if that makes sense.
You don’t have to change anything in the scene.

function create() {
gameState.rect1 = this.add.rectangle(200, 100, 100, 100, gameState.onColor);
gameState.rect2 = this.add.rectangle(200, 300, 100, 100, gameState.offColor);

// add the switchedOn state here
gameState.switchedOn = ‘rect1’;

// set gameState.rect2 as interactive here
gameState.rect2.setInteractive();

// create the pointerup listener for rect2 here
gameState.rect2.on(‘pointerup’, function() {
gameState.rect1.fillColor = gameState.offColor;
gameState.rect2.fillColor = gameState.onColor;
})
gameState.rect1.setInteractive();

gameState.rect1.on(‘pointerup’, function(){
** gameState.rect1.fillColor = gameState.onColor;**
** gameState.rect2.fillColor = gameState.offColor;**
** })**
}

#4

Hi uniq188, thx for your answer…but somehow, when I copy your code the preview stays white…same happened with my code ( I just didn’t have the switchedOn-state because it wasn’t really explained what this does in the task).

#5

I have seen no displays while doing ANY of the Phaser lessons. It sounds like mikewee is experiencing the same thing. the right hand window, labeled 'http://localhost:8000/,’ gives no display AT ALL. As I said in an earlier post, it’s hard to learn this if you don’t show the results of our work.

In this lesson it again states specifically ‘observe the two colors switch’. We can’t do that!

I’ve gone to the Phaser.io website and gone through their tutorials. It was the only way I could come back to codecademy and actually progress through the lesson, since I get NO VISUAL FEEDBACK on what I’m doing.

You really need to get this working before the course has any real value at all. It seems you’ve released the lesson before putting hints in place, verifying display, etc. Can’t give you any kudos on this lesson so far . . .

#6

Well TJ “Henry” Yoshi ^^

#7

Can someone please inform me where you’re getting the switchedOn function? There’s no explanation whatsoever about why this was included, and it’s not in the phaser docs.