1 decade ago by Fooshi
Hello,
My canvas is blank on the android browser ! there is no img or something else.
Here is my code :
My canvas is blank on the android browser ! there is no img or something else.
Here is my code :
ig.module( 'game.main' ) .requires( 'impact.game', 'impact.image', 'impact.loader', 'impact.input', 'impact.system' ) .defines(function(){ // Classe du Jeu TotemGame = ig.Game.extend({ FondCtx : null, first : new ig.Image('media/first.png'), init : function(){ ig.input.bind(ig.KEY.MOUSE1, 'scratch'); // Ecouteur de la souris var FondCanvas = document.getElementById("fond"); // Recupere le canvas de fond this.FondCtx = FondCanvas.getContext("2d"); this.first.draw(0,0); // Affiche l'image premiere }, update : function(){}, draw : function() { if(ig.input.state('scratch')) { var FondImg; for(var y=0; y<20; ++y) { var x = (Math.sqrt(400-(y*y))).round(); for(var i=0; i<x; ++i) { FondImg = this.FondCtx.getImageData(ig.input.mouse.x+i,ig.input.mouse.y+y,1,1); ig.system.context.putImageData(FondImg,ig.input.mouse.x+i,ig.input.mouse.y+y); FondImg = this.FondCtx.getImageData(ig.input.mouse.x-i,ig.input.mouse.y+y,1,1); ig.system.context.putImageData(FondImg,ig.input.mouse.x-i,ig.input.mouse.y+y); FondImg = this.FondCtx.getImageData(ig.input.mouse.x+i,ig.input.mouse.y-y,1,1); ig.system.context.putImageData(FondImg,ig.input.mouse.x+i,ig.input.mouse.y-y); FondImg = this.FondCtx.getImageData(ig.input.mouse.x-i,ig.input.mouse.y-y,1,1); ig.system.context.putImageData(FondImg,ig.input.mouse.x-i,ig.input.mouse.y-y); } } } } }); if(ig.ua.mobile) { ig.Sound.enabled = false; } if(ig.ua.iPhone4) { ig.main('#canvas', TotemGame, 60, 320, 480, 1); } else if(ig.ua.mobile) { ig.main('#canvas', TotemGame, 20, 320, 480, 1); } else { ig.main('#canvas', TotemGame, 60, 320, 480, 1); } }); // Init the background Canvas function init() { var fond = document.getElementById("fond"); var imageFond = new Image(); var imageFond1 = new Image(); if (fond.getContext) { ctx = fond.getContext("2d"); imageFond.onload = function() { ctx.drawImage(imageFond,0,0); } imageFond1.onload = function() { ctx.drawImage(imageFond1,0,0); } imageFond.src = "media/fond.jpg"; imageFond1.src = "media/euro1.png"; } }