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

1 decade ago by tarrent

Hi Everyone,

I've created a very simple, basic game, just to test OGG sounds for android. The game loads and sounds work when in desktop, but the loading bar stops when loaded on mobile.

Can you advice me what am I doing wrong?
P.S.: I've got both .mp3 and .ogg sound files available for the game.

The game can be accessed at:
http://tarrent.webs.com/test/androidos/


And the Entity that plays the sound is written like this:

ig.module(
    'game.entities.square'
)
.requires(
    'impact.game'
)
.defines(function(){
    EntitySquare = ig.Entity.extend({
        size: {x:48,y:48},
        animSheet: new ig.AnimationSheet('media/48x48.png', 48, 48),
        sfx_click: new ig.Sound('media/paytable.*'),
        sfx_bell: new ig.Sound('media/casino_bell.*'),
        sfx_cash: new ig.Sound('media/Cash.*'),
        soundOn: false,
        sprIndex: 0,
        
        init: function(x, y, settings){
            
            this.parent(x, y, settings);
            this.addAnim('idle', 0.1, [0]);
            this.currentAnim = this.anims.idle;
            
            if(settings.sprIndex != null){
                this.sprIndex = settings.sprIndex;
            }
            
        },
        
        update: function(){
            this.parent();
            
            if(ig.input.pressed('leftclick') && this.inRange()){
            
                
                switch(this.sprIndex){
                    case 0: this.sfx_click.play(); break;
                    case 1: this.sfx_bell.play(); break;
                    case 2: this.sfx_cash.play(); break;
                    default: break;
                }
            }
        },
        
        inRange: function(){
            var valid = 0;
            var isInRange = false;
            
            if(ig.input.mouse.x >= this.pos.x && ig.input.mouse.x <= (this.pos.x+this.size.x))
                valid++;
                
            if(ig.input.mouse.y >= this.pos.y && ig.input.mouse.y <= (this.pos.y+this.size.y))
                valid++;
                
            if(valid == 2) isInRange = true;
            
            return isInRange;
        }
    }); 
});

Thanks.

1 decade ago by dominic

Unfortunately, sound is almost impossible to get working on mobile in a meaningful way. Mobile browser's simply refuse to pre-load sounds, no matter what.

The easiest solution is to disable sound completely on those devices. See this article.

1 decade ago by tarrent

Thanks dominic, I have already ready that article. I have disabled Impact laden sounds from my other iOS game, and used a single audio sprite sheet instead.

But what baffles me is, I have used the same sound assets and same coding logic of this demo on that other game (referring only to android), and the OGG sounds load perfectly there while it does not anymore on this simple demo O_o.

I'll be providing the link to that other game later.

Thanks
Page 1 of 1
« first « previous next › last »