//Sample Solution
const gameState = {}
function preload() {
this.load.image('codey', 'https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png');
}
function create() {
gameState.codey = this.add.sprite(150, 200, 'codey')
// Set cursor keys here!
gameState.cursors = this.input.keyboard.createCursorKeys();
}
function update() {
// Update based on keypress here!
if(gameState.cursors.right.isDown){
gameState.codey.x += 5
}
if(gameState.cursors.left.isDown){
gameState.codey.x -= 5
}
if(gameState.cursors.up.isDown){
gameState.codey.y -= 5
}
if(gameState.cursors.down.isDown){
gameState.codey.y += 5
}
}
const config = {
type: Phaser.AUTO,
width: 400,
height: 500,
backgroundColor: "#5f2a55",
scene: {
preload,
create,
update
}
}
const game = new Phaser.Game(config)
Questions and Answers
Problems and Solutions
Quotes help make search much faster. Example: "Practice Makes Perfect"
Monday, September 9, 2019
Codecademy Learn Phaser: Basics Storing State 8/12
//Sample Solution
const gameState = {};
function create() {
gameState.circle = this.add.circle(40, 100, 20, 0xff9999)
}
function update() {
gameState.circle.y += 1
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#99ff99",
scene: {
create,
update
}
}
const game = new Phaser.Game(config)
const gameState = {};
function create() {
gameState.circle = this.add.circle(40, 100, 20, 0xff9999)
}
function update() {
gameState.circle.y += 1
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#99ff99",
scene: {
create,
update
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Move Your Bodies 7/12
//Sample Solution
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(30, 200, 'codey')
}
// Create your update() function here
function update() {
codey.x += 1;
}
const config = {
type: Phaser.AUTO,
width: 400,
height: 400,
backgroundColor: "#5f2a55",
scene: {
preload,
create,
// Include update here!
update
}
}
const game = new Phaser.Game(config)
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(30, 200, 'codey')
}
// Create your update() function here
function update() {
codey.x += 1;
}
const config = {
type: Phaser.AUTO,
width: 400,
height: 400,
backgroundColor: "#5f2a55",
scene: {
preload,
create,
// Include update here!
update
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Start Making A Scene 6/12
//Sample Solution
// Create a create() function here:
function create() {
this.add.text(100,170,"Spaze Invaydurs");
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#a0a0dd",
// Add in the scene information in the config here:
scene: {
create
}
}
const game = new Phaser.Game(config)
// Create a create() function here:
function create() {
this.add.text(100,170,"Spaze Invaydurs");
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#a0a0dd",
// Add in the scene information in the config here:
scene: {
create
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Create A Config 5/12
//Sample Solution
const config = {
width: 450,
height: 600,
backgroundColor: "#0000ff",
}
const game = new Phaser.Game(config)
const config = {
width: 450,
height: 600,
backgroundColor: "#0000ff",
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Draw A Background Image 4/12
//Sample Solution
function preload() {
// Load in the background image here!
this.load.image('sky','https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/sky.jpg');
}
function create() {
// Put the background image in the scene here!
this.add.image(200,200,'sky');
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create,
preload
}
}
const game = new Phaser.Game(config)
function preload() {
// Load in the background image here!
this.load.image('sky','https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/sky.jpg');
}
function create() {
// Put the background image in the scene here!
this.add.image(200,200,'sky');
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create,
preload
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Draw A Sprite 3/12
//Sample Solution
function preload() {
// Load in the sprite here!
this.load.image('codey','https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png')
}
function create() {
// Create a sprite game object here!
this.add.sprite(40,50,'codey')
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create,
preload
}
}
const game = new Phaser.Game(config)
function preload() {
// Load in the sprite here!
this.load.image('codey','https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png')
}
function create() {
// Create a sprite game object here!
this.add.sprite(40,50,'codey')
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create,
preload
}
}
const game = new Phaser.Game(config)
Subscribe to:
Posts (Atom)
This is an example of scrolling text using Javascript.
Popular Posts
-
//Sample Solution for MainController.js app.controller('MainController', ['$scope', function($scope) { $scope.title = ...
-
Question: What current is required for full scale deflection of a galvanometer having a current sensitivity of 50 micro-amperes per scale di...
-
Answer: This is the type of injury when a blow to the forehead causes a contusion of the eyeball due to the fracture of the bone at the r...
-
This is caused by the entrance of water into the air sacs which makes the lungs doughy, readily pits on pressure, exuding water and froth
-
var my_canvas=document.getElementById('canvas'); var context=my_canvas.getContext('2d');
-
#Sample Solution --- title: "Data Cleaning in R" output: html_notebook --- ```{r message=FALSE, warning=FALSE} # load libra...
-
# Update data types year_1_str = str(year_1) revenue_1_str = str(revenue_1) # Create a complete sentence combining only the string d...
-
//Sample Solution const gameState = {} function preload() { this.load.image('codey', 'https://s3.amazonaws.com/codecademy-...
-
Question: How do I startup Blend for Visual Studio once it has been installed? Answer: Click on the Windows button at the bottom left co...
-
Instructions: Count the number of rows from the flights table, where arr_time is not null and the destination is ATL. Sample Solution: S...