Search the Community

Showing results for tags 'extended class'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 2 results

  1. I’m trying to make a game with a rocket ship navigating in a cave. The cave is broken up into 400x400 big tiles that’s combined to form a bigger cave. They all have physics-maps from “PhysicsEditor” that seems to work correctly. My tileclass: export default class Tile extends Phaser.Physics.Matter.Sprite { constructor(scene, x, y, sprite, phymap) { super(, x, y, sprite, 0, { shape: phymap }); this.setStatic(true); this.setBounce(0.05); scene.add.existing(this); } } And these are added in game.js: tilemap[1][0] = new Tile(this, 0, 0, 'ground', tile_body.ground) tilemap[0][0] = new Tile(this, -400, 0, 'bottom-left', tile_body.bottom_left) tilemap[0][1] = new Tile(this, -400, -400, 'vertical', tile_body.vertical) But the tiles are all over the place, if I set them all on position (0, 0) you can see it more clearly: Any ideas to what I am doing wrong? I thought all would be on top of each other if created at position (0, 0) with the same height and width?
  2. Hello everyone. I'm learning about extending classes so excuse me if I'm asking a silly question. What I want is to get a variable from the state and use it in the extending class constructor and functions. The state looks similar to this MyGame.Game = function(){ this.tileSize = 80; }; MyGame.Game.prototype = { create: function(){ for(var i = 0; i < 8; i++){ for(var j = 0; j < 8; j++){ var tile = new Tile(this, i, j); this.add.existing(tile); } } } }; Then, I've a extended class like this: Tile = function(game, column, row){ var posX = game.tileSize * column; var posY = -game.tileSize + (game.tileSize * row);, game, posX, posY, "tile"); = game; }; Tile.prototype = Object.create(Phaser.Sprite.prototype); Tile.prototype.constructor = Tile; It works fine, it creates the tilegrid and I'm able to use the "tileSize" value I've defined in the state function. The problem happens when I try to add some animations to the tile class. If I add the "this.animations.add('shine'...)" command in the constructor, I get an error (this.animations is not defined) I've searched in the forum and I've found a solution, instead of "var tile = new Tile(this, i, j)" I should use "var tile = new Tile(, i, j)" That's correct, if I do that, I can add the animations, but then I cannot use the state variable "tileSize". Is there a way to do both things at the same time? Thanks a lot. Liranan.