Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript renderer #5

Open
GoogleCodeExporter opened this issue Jun 3, 2015 · 0 comments
Open

Javascript renderer #5

GoogleCodeExporter opened this issue Jun 3, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

Attached improvements to use of getAnimationFrame as per 
    https://gist.github.com/1002116

====
Also but not attached,  changed the way multiple animations are handled.

[snip]

function animate(dt)
{
    //loop through renderers
    for (var i = 0; i < renderers.length; i++) {
        //if running
        if (renderers[i].isRunning())
        {
            frame = renderers[i].getCurrentFrame();
            renderers[i].draw(frame);
            frame = (renderers[i].getCurrentFrame() + 1) % renderers[i].getAnimationLength();
            renderers[i].setCurrentFrame(frame);
        }
    }
}
[unsnip]

[snip]
    gameTimer = new fpstimer.FPSTimer(25, animate);

[unsnip]

[snip]
    require(["json!upload/sheep_right_flower.php"], function (json) {
        // create renderer
        var renderer = new renderModule.Renderer(json, {
            onDone: function(renderer) {
                sheep_anim = setupAnimation(renderer, fpstimer, "sheep2-wrap");
                sheep_anim.start();
                gameTimer.start();
            }
        });
    });


    require(["json!upload/cows.php"], function (json) {
        // create renderer
        var renderer = new renderModule.Renderer(json, {
            onDone: function(renderer) {
                cows_anim = setupAnimation(renderer, fpstimer, "cows-wrap");
                cows_anim.start();
            }
        });
    });

    require(["json!upload/farmer_win_data.php"], function (json) {
        // create renderer
        var renderer = new renderModule.Renderer(json, {
            onDone: function(renderer) {
                farmer_win_anim = setupAnimation(renderer, fpstimer, "farmer-win-wrap");
                winSound = loadSound("clapp");
            }
        });
    });

Original issue reported on code.google.com by [email protected] on 20 Aug 2012 at 11:27

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant