Miresnare Posted February 26, 2015 Report Share Posted February 26, 2015 Hi all. I've just started playing around with PandaJS and am very impressed so far. However, the demo I've throw together in 1.10.1 doesn't work in 1.13.1: - TypeError: game[extend].extend is not a functionreturn game[name] = game[extend].extend(content); I've tracked it down to this code: - game.createClass('Player', 'Sprite', {... Can anyone shed some light on what I'm doing wrong? Thanks in advance. Link to comment Share on other sites More sharing options...
enpu Posted February 26, 2015 Report Share Posted February 26, 2015 You should not extend Pixi classes (Sprite, Container etc) Link to comment Share on other sites More sharing options...
Miresnare Posted February 27, 2015 Author Report Share Posted February 27, 2015 You should not extend Pixi classes (Sprite, Container etc) Thanks for the reply. I've just found the demo games for this build, and am converting across what I've done. Link to comment Share on other sites More sharing options...
martinez Posted March 2, 2015 Report Share Posted March 2, 2015 You should not extend Pixi classes (Sprite, Container etc) enpu, could you explain the reason for that? Link to comment Share on other sites More sharing options...
enpu Posted March 3, 2015 Report Share Posted March 3, 2015 @martinez Panda classes are using class inheritance (base on this http://ejohn.org/blog/simple-javascript-inheritance/),while Pixi classes use basic JavaScript object prototypes. Link to comment Share on other sites More sharing options...
19871986 Posted November 16, 2015 Report Share Posted November 16, 2015 whats mean "should not extend Pixi classes" Code is dev.html which downloaded from panda.js if need to do extend pixi classes why they didnt do it for us ? Im just beginner.<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>Online -</title> <script type="text/javascript" src="src/game/config.js"></script> <script type="text/javascript" src="src/engine/core.js"></script> <script type="text/javascript">game.module( 'game.main').body(function() {game.addAsset('panda.png');game.createClass('Panda', 'Sprite', { interactive: true, mouse: {x:100, y: 100}, init: function(x, y){ this._super('panda.png', x, y, {anchor: { x: 0.5, y: 0.5 }}); this.position = {x: x, y: y}; //body this.body = new game.Body({ position: { x: x, y: y }, velocityLimit: { x: 150, y: 150 }, velocity: {x:-100,y:-50}, collisionGroup: 1, collideAgainst: 0, mass: 0 }); this.body.addShape(new game.Rectangle(60, 60)); //add sprite to scene game.scene.addObject(this); //add body of this sprite to the world object game.scene.world.addBody(this.body); //add sprite to display container game.scene.stage.addChild(this); }, update: function(){ this.position.x = this.body.position.x; this.position.y = this.body.position.y; this.body.velocity.x = (this.mouse.x - this.body.position.x); this.body.velocity.y = (this.mouse.y - this.body.position.y); }, remove: function() { game.scene.removeObject(this); game.scene.world.removeBody(this.body); game.scene.stage.removeChild(this); }, mousemove: function(e) { this.mouse.x = e.global.x; this.mouse.y = e.global.y; } });game.createScene('Main', { backgroundColor: 0xb9bec7, init: function() { this.world = new game.World(0, 0); var panda = new game.Panda(300,200); }});}); </script></head><body></body></html> Link to comment Share on other sites More sharing options...
Recommended Posts