Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

9 years ago by Vincent

Hi friends, the FPS go down everytime is launched a sound. To fix this issue i have disabled all sounds. This solution is not the solution. How to play sound without lag issue? This problem is only on safari for mac. Thanks at all!

9 years ago by Joncom

Are you preloading your sounds? If not, make sure you are to ensure the smoothest experience.

http://impactjs.com/documentation/working-with-assets#using-the-preloader

9 years ago by Vincent

Hi, sure i use my custom preloader this is the code:

ig.module("game.loader").requires("impact.loader").defines(function() {
    MyLoader = ig.Loader.extend({
        image: null,
        imageLoaded: false,
        imageAlpha: 0,
        load: function() {
            this.image = new Image;
            var parentMethod = this.parent.bind(this);
            this.image.onload = function() {
                this.imageLoaded = true;
                parentMethod();
                ig.system.clear("#fff")
            }.bind(this);
            this.image.src = ig.prefix + "media/logo.png" + ig.nocache
        },
        draw: function() {
            this._drawStatus += (this.status - this._drawStatus) / 5;
            var s = ig.system.scale;
            var w = ig.system.width * .6;
            var h = ig.system.height * .025;
            var x = ig.system.width * .5 - w / 2;
            var y = ig.system.height * .65 - h / 2;
            ig.system.context.fillStyle = "#fff";
            ig.system.context.fillRect(0, 0, ig.system.width, ig.system.height);
            ig.system.context.fillStyle = "#3283C4";
            ig.system.context.fillRect(x * s, y * s, w * s, h * s);
            ig.system.context.fillStyle = "#fff";
            ig.system.context.fillRect(x * s + s * 2, y * s + s * 2, w * s - s - s * 3, h * s - s - s * 3);
            ig.system.context.fillStyle = "#3283C4";
            ig.system.context.fillRect(x * s, y * s, w * s * this._drawStatus, h * s);
            if (this.imageLoaded) {
                this.imageAlpha = (this.imageAlpha + .1).limit(0, 1);
                ig.system.context.save();
                ig.system.context.globalAlpha = this.imageAlpha;
                ig.system.context.drawImage(this.image, ig.system.width * .5 - this.image.width / 2, ig.system.height * .45 - this.image.height / 2);
                ig.system.context.restore()
            }
        }
    })
});


Where is the problem?

9 years ago by Joncom

I meant the built-in preloader.

Does lag happen only the first time a particular sound plays, or every time?
Page 1 of 1
« first « previous next › last »