Jump to content


Recommended Posts

Phaser Game with ES6

Phaser object orientation with objects and class. We do not use prototype

See one example class file

class Items extends Phaser.Sprite {
  constructor(game,sprite) {
    var arrEnemyX = [500,1500,1800,1300,1400,1900,2200,2500,1701,2250];
    var arrEnemyY = [1200,1400,2000,2100,1000,1250,1650,1450,2101,2021];

    var vx = Math.floor((Math.random()*10)+0);
    var vy = Math.floor((Math.random()*10)+0);
    this.scale.setTo(1.1, 1.1);
    this.frame = 9;

    this.body.collideWorldBounds = true;
    this.body.allowGravity = false;

    this.effects = game.add.group();
    for (var i = 0; i < 20; i++)
        this.effect = this.effects.create(0, 0, 'effectRing', [0], false);
    this.animations.add('left', l, 10, true);
    this.animations.add('right',r, 10, true);
    this.animations.add('up',   u, 10, true);
    this.animations.add('down', d, 10, true);

see more in this proyect https://github.com/pardeep4e/Proyecto-DAW-2015-2016

Link to comment
Share on other sites

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...