Jump to content

Search the Community

Showing results for tags 'inheritance'.

  • 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 10 results

  1. Hello! I'm trying to refactor my code making some inheritance. I'm using a Character prototype which is supposed to inherit from Phaser.Sprite and then there can be - for example - a Player prototype which inherits from the Character. The problem is that i get this error: this.onTextureUpdate is not a function inside phaser.js when trying to create the Player object inside the create-function of the level. I would be greatful if someone could take a look on this. Here is the code relevant to the issue (I think) (It's in separate files): Character = function(game, x, y, type){ Phaser.
  2. Hi, I have been going through a tutorial on recreating FruitNinja (unimportant maybe). I am a beginner in JS with experiance in Java. I need some help or reference where to get it - I have 2 states like this: var FruitNinja = FruitNinja || {}; FruitNinja.JSONLevelState = function () { "use strict"; Phaser.State.call(this); }; FruitNinja.JSONLevelState.prototype = Object.create(Phaser.State.prototype); FruitNinja.JSONLevelState.prototype.constructor = FruitNinja.JSONLevelState; (...) FruitNinja.JSONLevelState.prototype.create = function () { this.create_prefab(prefab_name, t
  3. Hi everyone, I'm trying to create two types of enemies, the first is a robot that has 2 methods: sleep and patrol. My second enemy is a flyingEnemy. The aim is to inherit the sleep method from the robot but amend the patrol method. Can anyone show me how my flyingEnemy can inherit from robot whilst amending the patrol method? Below is my code. When I create the flyingEnemy, its patrol method overwrites the robot's patrol method and ALL enemies have the same behavior. var SuperSmash = SuperSmash || {}; SuperSmash.flyingEnemy = function(game, x, y, key, velocity
  4. Hi people, I'm extending the Sprite class with a class named "Being", which I further extend with two child classes, "Monster" and "Player". But it doesn't work. Here is first the code for my classes. function Being(x,y,key){ Phaser.Sprite.call(this, game, x,y,key); game.add.existing(this); } Being.prototype = Object.create(Phaser.Sprite.prototype); Being.prototype.constructor = Being; function Player(x,y,key){ Being.call(x,y,key); } Player.prototype = Object.create(Being.prototype); Player.prototype.constructor = Player; function Monster(x,y,key){ Being.call(x,y,key
  5. Hello, recently I found code that is defining objects inheriting from Phaser.Sprite (if I google'd it and understood correctly). Can someone explain a little more about Phaser.Sprite.call() function? I haven't found it anywhere in docs. Also, what are the possible parameters? I found an example of code on some flappy bird tutorial : Pipe = function (game, x, y, speed) { Phaser.Sprite.call(this, game, x, y, "pipe"); game.physics.enable(this, Phaser.Physics.ARCADE, this); this.body.velocity.x = speed; this.giveScore = true; }; Pipe.prototype = Object.create(Phaser.Spr
  6. Can the 'create' function in Phaser.Group be successfully over-ridden? Is there an alternative? I am looking for a way to have a function called at the start of my object's life-cycle and still be able to access the functions I have built into the class. I am used to Unity3D where there is always an option to do this. There is certain code that I need to execute at the start of my object's life-cycle, and additionally whenever the level ID is set in my function. Am I being clear, or have I worded this too confusingly? Thanks much! FriarDude.FallingShitFactory = function (game) { // Class
  7. So I try to make inheriting to my game, but it says "peli is not defined". Where and how I need to define it? player.js: var HardDrive = HardDrive || {};HardDrive.Player = function (peli, x, y) { Phaser.Sprite.call(this, peli, x, y, 'auto'); peli.add.existing(this);};HardDrive.Player.prototype = Object.create(Phaser.Sprite.prototype);HardDrive.Player.constructor = HardDrive.Player;game.js: this.pelaaja = new HardDrive.Player(peli, 500, 380);
  8. Hello, I'm still learning Phaser. I'm familiar with OOP Perspective. But from what I learnt from many tutorial in Phaser, Phaser does not have obvious OOP-perspective. So the tutorial use a workaround to it. For example, if I want to have a customized draggable sprite (with spesific dragDrop eventhandler). I need to create an object, which have a properties (pointer) to sprite. I can then use the sprite as the object itself (sort of wrap the sprite with my custom object method and properties). This approach is simple when used in simple object, but I can see this might create some proble
  9. Hi everyone, I'm trying to create a clean HUD class using Phaser 2.0.7 but I am getting a weird error: "Uncaught TypeError: Cannot read property 'x' of undefined " I created a separate hud.js file with the following code: function HeadUpDisplay(game, parent, name, useStage){ Phaser.Group.call(this, game); var fpsCounter = new Phaser.Text(0,0, "test", { font: "16px Arial", fill: "#ff0044" }); fpsCounter.fixedToCamera = true; this.add(fpsCounter); this.update = function() { fpsCounter.setText(game.time.fps); };};HeadUpDisplay.prototype = Object.creat
  10. Apologies for the repost, the other thread is very old and marked as 'answered' so I think my question is not being seen by the people who know... Is Sprite inheritance broken in the current Main branch? I'm getting "error: undefined is not a function" on line 1719 of Phaser.js: this.onTextureUpdate(); from this code: Person = function(game) { Phaser.Sprite.call(this, game, 0, 0, 'person'); }; Person.prototype = Object.create(Phaser.Sprite.prototype); Person.prototype.constructor = Person; invoked by: var person = new Person(game); The reason I want to do this is to make a Grou
  • Create New...