Jump to content

Only Play SpriteSheet Animation / MovieClip Once


Kenyon
 Share

Recommended Posts

Hey @themoonrat, unfortunatly I have tried that but for some reason it doesn't play through once, it just loads the last frame.

Here's what I have:

        window.onload = function() {
            var renderer = PIXI.autoDetectRenderer(1000, 620, { transparent: true });
            document.body.appendChild(renderer.view);

            // create the root of the scene graph
            var stage = new PIXI.Container();

            var background = new PIXI.Sprite.fromImage('city4.png');
            background.setParent(stage);

            PIXI.loader.add('./data.json').load(onAssetsLoaded);

            var movie;

            function onAssetsLoaded() {
                var frames = [];


                for (var i = 0; i < 38; i++) {
                  var val = i < 10 ? i : i;
                  frames.push(PIXI.Texture.fromFrame('texture' + val + '.png'));
                }

                movie = new PIXI.extras.MovieClip(frames);
                movie.position.set(1000, 620);
                movie.anchor.set(1);
                movie.animationSpeed = -0.2;
                movie.play();
                movie.loop = false;

                stage.addChild(movie);

                animate(movie);
            }

            function animate(movie) {
              renderer.render(stage);
              requestAnimationFrame(animate);
            }
        }

 

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...