Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable class-methods-use-this */
import * as Phaser from 'phaser';
import { CST } from '../CST';
export default class MenuScene extends Phaser.Scene {
constructor() {
super({
key: CST.SCENES.MENU,
});
}
init(data) {
console.log(data);
}
create() {
this.sound.play('title_music', {
loop: true,
});
const lava = this.add.particles('lava').setDepth(1);
/* global localStorage */
import Phaser from 'phaser'
import gameOptions, { directions } from '../game-options'
const { DOWN, LEFT, RIGHT, UP } = directions
class PlayGame extends Phaser.Scene {
constructor () {
super('PlayGame')
}
create () {
this.score = 0
const restartXY = this.getTilePosition(-0.8, gameOptions.boardSize.cols - 1)
const restartButton = this.add.sprite(restartXY.x, restartXY.y, 'restart')
restartButton.setInteractive()
restartButton.on('pointerdown', function () {
this.scene.start('PlayGame')
}, this)
const fullScreenButton = this.add.sprite(restartButton.x,
restartButton.y - 120, 'fullscreen')
import Phaser from 'phaser';
export default class BootScene extends Phaser.Scene
{
constructor ()
{
super({ key: 'boot' });
}
preload ()
{
// load all files necessary for the loading screen
this.load.json('assets', 'assets/json/assets.json');
this.load.image('logo', 'assets/image/logo.png');
}
create ()
{
this.scene.start('preload');
import Phaser from 'phaser';
import image from './../../assets/images/logo.png';
import audioMP3 from './../../assets/audio/medieval_music.mp3';
import audioOGG from './../../assets/audio/medieval_music.ogg';
class BootScene extends Phaser.Scene {
constructor() {
super({ key: 'Boot' });
}
preload() {
// Load all images sounds sprite.
this.load.image('logo', image);
}
create() {
this.add.text(10, 10, 'Phaser 3 Advanced webpack boilerplate');
this.add.image(300, 300, 'logo');
}
}
export default BootScene;
import _ from 'lodash';
import Phaser from 'phaser';
import levelImages from '../assets/levels/processed/level-0/images.js';
import level from '../assets/levels/processed/level-0/level-0.json';
import sounds from '../assets/sounds/processed';
import constants from '../config/constants';
import Player from '../sprites/player';
const { WIDTH, HEIGHT, SCALE } = constants;
export default class Game extends Phaser.Scene {
constructor() {
super({ key: 'Game' });
}
preload() {
this.preloadBackground();
//map
this.load.image('tiles', levelImages['rock-moss-plants-doors']);
console.log(level);
this.load.tilemapTiledJSON('level-0', level);
let playerSpawnLayer = _.find(level.layers, { name: 'Player-Spawn' });
if (playerSpawnLayer) {
import Phaser from 'phaser'
import SocketIO from 'socket.io-client'
import { ROOM } from '../constants/scenes.js'
import Config from '../../../../config.json'
import { TILE, PLAYER } from '../constants/assets.js'
import { UP, LEFT, DOWN, RIGHT } from '../../../common/constants/directions.js'
import Room from './room.js'
import Player from './player.js'
class RoomScene extends Phaser.Scene {
constructor() {
super({ key: ROOM })
}
preload() {
this.load.path = 'web-build/'
this.load.image(TILE, 'images/tile.png', { frameWidth: 32, frameHeight: 32 })
this.load.spritesheet(PLAYER, 'sprites/player.png', { frameWidth: 32, frameHeight: 32 })
}
init() {
let socket = SocketIO(`${Config.server.protocol}://${Config.server.host}:${Config.server.port}`)
this.room = new Room(this, socket, 0)
this.player = new Player(this, socket, 0, { x: 0, y: 0, direction: DOWN })
}
const Phaser = require('phaser');
const TilesetAnimation = require('./tileset-animation');
const Player = require('../objects/player');
var share = require('../../shared/constants');
class BaseScene extends Phaser.Scene
{
constructor(key)
{
super({key});
this.key = key;
}
init(position)
{
this.scene.setVisible(false, this.key);
if(!this.player && this.game.colyseusRoom){
this.player = new Player(this, this.key, position);
this.player.socket = this.game.colyseusRoom;
this.player.playerId = this.game.colyseusRoom.sessionId;
}
import * as Phaser from "phaser";
class Hello extends Phaser.Scene {
public constructor() {
super({ key: "hello" });
}
public preload() {
this.load.json("level:0", "data/level00.json");
this.load.json("level:1", "data/level01.json");
this.load.json("level:2", "data/level02.json");
this.load.bitmapFont("font", "images/font.png", "images/font.fnt");
this.load.image("icon:coin", "images/coin_icon.png");
this.load.image("background", "images/background.png");
this.load.image("invisible-wall", "images/invisible_wall.png");
this.load.image("ground", "images/ground.png");
this.load.image("grass:8x1", "images/grass_8x1.png");
this.load.image("grass:6x1", "images/grass_6x1.png");
initialize: function() {
Phaser.Scene.call(this, {key: "PlayGame"})
},
preload: function () {
import * as Phaser from "phaser";
class Hello extends Phaser.Scene {
public constructor() {
super({ key: "hello" });
}
public preload() {
this.load.image("background", "assets/images/background.png");
//
this.load.spritesheet("ship", "assets/spritesheets/ship.png", {
frameWidth: 16,
frameHeight: 16
});
this.load.spritesheet("ship2", "assets/spritesheets/ship2.png", {
frameWidth: 32,
frameHeight: 16
});
this.load.spritesheet("ship3", "assets/spritesheets/ship3.png", {
frameWidth: 32,