Miresnare Posted February 26, 2015 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. Quote Link to comment Share on other sites More sharing options...
enpu Posted February 26, 2015 Share Posted February 26, 2015 You should not extend Pixi classes (Sprite, Container etc) Quote Link to comment Share on other sites More sharing options...
Miresnare Posted February 27, 2015 Author 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. Quote Link to comment Share on other sites More sharing options...
martinez Posted March 2, 2015 Share Posted March 2, 2015 You should not extend Pixi classes (Sprite, Container etc) enpu, could you explain the reason for that? Quote Link to comment Share on other sites More sharing options...
enpu Posted March 3, 2015 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. Quote Link to comment Share on other sites More sharing options...
19871986 Posted November 16, 2015 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.