newBie here Posted July 7, 2019 Share Posted July 7, 2019 Hello i have some problems with pixi-layers.js. I want to move some sprites to top. I use pixi.v4 with this script: https://github.com/pixijs/pixi-layers/blob/layers/dist/pixi-layers.js Error message i get: pixi-layers.js:705 Uncaught TypeError: Cannot read property 'prototype' of undefined at pixi-layers.js:705 at pixi-layers.js:744 I add pixi layers in index.html this way: <script src="/socket.io/socket.io.js"></script> <script src="https://pixijs.download/v4.4.2/pixi.min.js"></script> <script src="src/pixi-layers.js"></script> <script src="src/keyboard.js"></script> <script src="src/client.js"></script> What did i do wrong? Thank you for your time. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 7, 2019 Share Posted July 7, 2019 It should work. Try not-minified pixi. Or try latest pixi-v4 (4.8.8) Please post your example somewhere so I can debug it. Quote Link to comment Share on other sites More sharing options...
newBie here Posted July 7, 2019 Author Share Posted July 7, 2019 5 minutes ago, ivan.popelyshev said: It should work. Try not-minified pixi. Or try latest pixi-v4 (4.8.8) Please post your example somewhere so I can debug it. http://fx-team.fulara.com/team/adam/zombie apocalypse.rar As you can see in my game when zombie is killed i am changing its texture to blood and its cover others sprites. Can you look at my code and do code review? Should i change something? Its my first multiplayer game so every tip will be appreciated Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 7, 2019 Share Posted July 7, 2019 Nope, the script you took is from master branch (v5), not "layers" (v4). Take it from the link you posted > when zombie is killed i am changing its texture to blood and its cover others sprites yeah, layers is good for that. > Its my first multiplayer game so every tip will be appreciated That's at least several days discussion in discord. You can find me in https://discord.gg/PDQdDG as "Hackerham", but i dont know if i have time for it this week. Quote Link to comment Share on other sites More sharing options...
newBie here Posted July 7, 2019 Author Share Posted July 7, 2019 Ah okay, stupid mistake I have no errors now. Its hard to me to understand how this work, and i dont know what am i doing lol So i have this code var type = "WebGL" if (!PIXI.utils.isWebGLSupported()) { type = "canvas" } const app=new PIXI.Application(1000,800,{ transparent:false, backgroundColor:'0x000000' }); document.body.appendChild(app.view); //var layer = new PIXI.display.Layer(); //stage.addChild(layer); var container = new PIXI.Container(); app.stage.addChild(container); /*var enemiesGroup = new PIXI.display.Group(0, true); enemiesGroup.on('sort', function(sprite) { sprite.zOrder = 1; });*/ var playersGroup = new PIXI.display.Group(1, function(sprite) { sprite.zOrder = 3; }); var enemiesGroup = new PIXI.display.Group(1, function(sprite) { sprite.zOrder = 2; }); app.stage = new PIXI.display.Stage(); app.stage.group.enableSort = true; //layers app.stage.addChild(new PIXI.display.Layer(enemiesGroup)); app.stage.addChild(new PIXI.display.Layer(playersGroup)); var enemyArr = []; var enemyController = function() { this.enemy = null; this.id = 0; this.init = function (cords, id) { this.enemy = new PIXI.Sprite(texture_zombie); this.enemy.anchor.set(0.5); this.enemy.x = cords.x; this.enemy.y = cords.y; this.enemy.visible = true; this.enemy.parentGroup = enemiesGroup; //group this.id = id; container.addChild(this.enemy); }; } Is it enough? I think not because now my sprites disappeared 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.