Jump to content

Using ParticleContainer


brdmg
 Share

Recommended Posts

Recently I've been developing small app for raspberry pi with few sets of sprites. I used PIXI.Container as stage for rendering with MovieClip objects inside of it. And it works fine.

Then I tried to improve perfomances and changed PIXI.Container to PIXI.ParticleContainer(5000, {uvs: true }); It works fine on pc, but on pi i get error "TypeError: null is not an object (evaluating 'this.parent.transform')" which occurs in this part of pixi 

DisplayObject.prototype.updateTransform = function ()
{
   this.transform.updateTransform(this.parent.transform);
    // multiply the alphas..
    this.worldAlpha = this.alpha * this.parent.worldAlpha;

    this._bounds.updateID++;
};
 

I tested this part and it's used by PIXI.ParticleContainer and not PIXI.Container and i was wondering can i somehow avoid using this part of code 

Link to comment
Share on other sites

my code is pretty straightforward so I'll write in short lines

var renderer = new PIXI.autoDetectRenderer(300, 300, {transparent: true});

var stage = new PIXI.ParticleContainer(5000, {uvs: true});

stage.appendChild(renderer.view);

then i load assets and create MovieClip object and append it to stage

function createAnimation() {

            var frames = [];
            for(var i=75; i<150; i++) {
                frames.push(new PIXI.Texture(resources.texture, new PIXI.Rectangle(imgData[2],imgData[3], 238, 235))); //imgData is json with frames positions
            }

            return new PIXI.extras.MovieClip(frames);

}

So, i traced call stack and came up with this

-It starts from WebGLRenderer.prototype.render

 if(!skipUpdateTransform)
    {
        // update the scene graph
        var cacheParent = displayObject.parent;
        displayObject.parent = this._tempDisplayObjectParent;
        displayObject.updateTransform();
        displayObject.parent = cacheParent;
       // displayObject.hitArea = //TODO add a temp hit area
    }

ParticleContainer.prototype.updateTransform = function ()
{

    // TODO don't need to!
    this.displayObjectUpdateTransform();
    //  PIXI.Container.prototype.updateTransform.call( this );
};

 

DisplayObject.prototype.updateTransform = function ()
{
    this.transform.updateTransform(this.parent.transform); // error
    // multiply the alphas..
    this.worldAlpha = this.alpha * this.parent.worldAlpha;

    this._bounds.updateID++;
};

Maybe I'm using wrong way for creating MovieClip?

 

Link to comment
Share on other sites

 

var renderer = new PIXI.autoDetectRenderer(300, 300, {transparent: true});

var stage = new PIXI.ParticleContainer(5000, {uvs: true});

stage.appendChild(renderer.view);

You don't want that. You added the canvas of the renderer to the particle container, I think you meant to add the canvas to the document with document.body.appendChild(renderer.view). That may be causing your issue.

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...