1

I am working on a project using Meteor with Pixi.js, and I'm facing a very strange problem when I try to use a router (I tried both IronRouter and FlowRouter), and a pixi canvas.

The canvas is built, but i cant render any sprite on it. This happen only when i use a route parameter, such as '/game/:id'

This is working except when i use a route parameter, such as '/game/:id' More, if i dont use route parameter, Sprite is showing up when i access '/game' Sprite doesn't show up when i access '/game/

Here is a minimal error code on a meteor app :

Any Router definition :

Router.route('/room/:_id', {
    action: function() {
        this.render('game');
    }
});

A basic template : Html :

<template name="game"></template>

Js :

Template.game.onRendered(function () {
PIXI.loader.add("assets/mario.png")
    .load(() => {
        let app = new PIXI.Application();
        document.body.appendChild(app.view);
        let mario = new PIXI.Sprite(PIXI.loader.resources["assets/mario.png"].texture);
        mario.position.set(5, 5);
        mario.width = 48;
        mario.height = 48;
        app.stage.addChild(mario);
        app.render();
    });
});

The pixi canvas will show up but mario sprite doesn't.

3
  • Is there a reason you're appending the canvas to body and not to the template? Blaze mounts on the body by default, which is probably wiping away your canvas as a result Commented Nov 23, 2017 at 22:07
  • Try putting a container div inside your game template and appending your canvas to that Commented Nov 23, 2017 at 22:07
  • I actually append the canvas to a div in the template, and got the same error. I did use document.body on my post, cause i am not sure pixi users will be aware of blaze works, and i wanted to respect their basic example. Commented Nov 24, 2017 at 12:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.