Tabnine Logo For Javascript
phaser
Code IndexAdd Tabnine to your IDE (free)

How to use phaser

Best JavaScript code snippets using phaser(Showing top 11 results out of 315)

origin: geckosio/phaser-on-nodejs

constructor(scene, x, y) {
  // pass empty string for the texture
  super(scene, x, y, '')

  scene.add.existing(this)
  scene.physics.add.existing(this)

  // set the width and height of the sprite as the body size
  this.body.setSize(32, 48)
 }
origin: aaron5670/PokeMMO-Online-Realtime-Multiplayer-Game

preload() {
    // Load Town
    this.load.image("TilesTown", TilesTown);
    this.load.tilemapTiledJSON("town", TownJSON);

    // Load Route1
    this.load.tilemapTiledJSON("route1", Route1JSON);

    // Load atlas
    this.load.atlas("currentPlayer", AtlasPNG, AtlasJSON);
    this.load.atlas("players", PlayersAtlasPNG, PlayersAtlasJSON);
  }
origin: geckosio/phaser-on-nodejs

it('should multiply to 528 (24*22)', done => {
 class MainScene extends Phaser.Scene {
  preload() {
   this.load.image('star', '../assets/star.png')
  }

  create() {
   const star = this.physics.add.sprite(400, 300, 'star')
   expect(star.body.width * star.body.height).toBe(528)
   done()
  }
 }

 StartTest([MainScene])
})
origin: geckosio/phaser-on-nodejs

const StartGame = Scenes => {
 const config = {
  type: Phaser.HEADLESS,
  width: 1280,
  height: 720,
  banner: false,
  audio: false,
  scene: Scenes,
  physics: {
   default: 'arcade',
   arcade: {
    gravity: { y: 300 },
   },
  },
 }

 new Phaser.Game(config)
}
origin: geckosio/phaser-on-nodejs

it('should load both scenes', done => {
 class PreloadScene extends Phaser.Scene {
  constructor() {
   super('PreloadScene')
  }
  create() {
   this.scene.start('MainScene')
  }
 }

 class MainScene extends Phaser.Scene {
  constructor() {
   super('MainScene')
  }
  create() {
   done()
  }
 }

 StartTest([PreloadScene, MainScene])
})
origin: geckosio/phaser-on-nodejs

it('body size should be 32 * 48 (1536)', done => {
 class Player extends Phaser.Physics.Arcade.Sprite {
  constructor(scene, x, y) {
   // pass empty string for the texture
   super(scene, x, y, '')

   scene.add.existing(this)
   scene.physics.add.existing(this)

   // set the width and height of the sprite as the body size
   this.body.setSize(32, 48)
  }
 }

 class MainScene extends Phaser.Scene {
  create() {
   this.player = new Player(this, 100, 100)
  }

  update(time, delta) {
   expect(this.player.body.width * this.player.body.height).toBe(1536)
   done()
  }
 }

 StartTest([MainScene])
})
origin: geckosio/phaser-on-nodejs

 global.phaserOnNodeFPS = FPS
 class MainScene extends Phaser.Scene {
  constructor() {
   super('MainScene')
  type: Phaser.HEADLESS,
  width: 1280,
  height: 720,
 new Phaser.Game(config)
})
origin: aaron5670/PokeMMO-Online-Realtime-Multiplayer-Game

create() {
    this.add.text(20, 20, "Loading game...");
    this.scene.start("playGame", {map: 'town', playerTexturePosition: 'front'});
    this.anims.create({
      key: "misa-left-walk",
      frames: this.anims.generateFrameNames("currentPlayer", {
        prefix: "misa-left-walk.",
        start: 0,
      repeat: -1
    });
    this.anims.create({
      key: "misa-right-walk",
      frames: this.anims.generateFrameNames("currentPlayer", {
        prefix: "misa-right-walk.",
        start: 0,
      repeat: -1
    });
    this.anims.create({
      key: "misa-front-walk",
      frames: this.anims.generateFrameNames("currentPlayer", {
        prefix: "misa-front-walk.",
        start: 0,
      repeat: -1
    });
    this.anims.create({
origin: geckosio/phaser-on-nodejs

class MainScene extends Phaser.Scene {
 preload() {
  this.load.image('tiles', '../assets/gridtiles.png')
  this.load.tilemapTiledJSON('map', '../assets/simple-map.json')
  const map = this.make.tilemap({
   key: 'map',
   tileWidth: 32,
   tileHeight: 32,
  })
  const tileset = map.addTilesetImage('tiles')
  const layer = map.createDynamicLayer('Level1', tileset)
  map.setCollision([20, 48])
  this.player = this.physics.add.sprite(96, 96, '')
  this.player.body.setSize(24, 38)
  this.physics.add.collider(this.player, layer)
  if (this.player.body.onFloor()) {
   done()
origin: geckosio/phaser-on-nodejs

it('should render at 30 fps (+-5 fps)', done => {
 class MainScene extends Phaser.Scene {
  constructor() {
   super('MainScene')
  type: Phaser.HEADLESS,
  width: 1280,
  height: 720,
 new Phaser.Game(config)
})
origin: geckosio/phaser-on-nodejs

it('should multiply to 1536 (32*48)', done => {
 class MainScene extends Phaser.Scene {
  preload() {
   this.load.spritesheet('dude', '../assets/dude.png', {
    frameWidth: 32,
    frameHeight: 48,
   })
  }

  create() {
   const dude = this.physics.add.sprite(100, 450, 'dude')
   expect(dude.body.width * dude.body.height).toBe(1536)
   done()
  }
 }

 StartTest([MainScene])
})
phaser(npm)

Most used phaser functions

  • LoaderPlugin.image
  • LoaderPlugin.tilemapTiledJSON
  • ScenePlugin.start
  • AnimationManager.create
  • AnimationManager.generateFrameNames
  • ArcadePhysics.add,
  • Body.height,
  • Body.onFloor,
  • Body.setSize,
  • Body.width,
  • Factory.collider,
  • Factory.sprite,
  • Game,
  • Game.Game,
  • GameObjectCreator.tilemap,
  • GameObjectFactory.text,
  • HEADLESS,
  • LoaderPlugin.atlas,
  • LoaderPlugin.spritesheet

Popular in JavaScript

  • http
  • mime-types
    The ultimate javascript content-type utility.
  • lodash
    Lodash modular utilities.
  • path
  • body-parser
    Node.js body parsing middleware
  • ms
    Tiny millisecond conversion utility
  • minimatch
    a glob matcher in javascript
  • readable-stream
    Streams3, a user-land copy of the stream library from Node.js
  • rimraf
    A deep deletion module for node (like `rm -rf`)
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now