Description

Shakes the screen

Usage

Parameters

  • power {Integer}

    Intensity of the shake. The higher the value, the greater the shaking is strong

  • speed {Integer}

    Speed of the shake.

  • duration {Integer}

    Duration of shake in frame

  • axis {String} optional

    (optional) The axis where there will shake : "x", "y" or "xy". "x" by default

  • callback {Function} optional

    (optional) Callback when the shake is completed

Example

canvas.Scene.new({
    name: "MyScene",

    materials: {
        images: {
            "img": "images/foo.png"
        }
    },

    ready: function(stage) {
        var el = this.createElement();
            el.drawImage("img");

        stage.append(el);

        var effect = canvas.Effect.new(this, el);
        effect.shake(3, 5, 24);
    }
});

Other example :

effect.shake(3, 5, 24, "xy");

or :

effect.shake(3, 5, 24, "xy", function() { // You can omit the parameter "axis" if you do a shake on the X axis
    alert("finish"); 
});

Discussion