Recommended Posts

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.

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

Ah okay, stupid mistake :D
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

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.