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 Fooshi

Hello,
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";			
	}	
}


1 decade ago by Husten

did you check it with safari? perhaps its an error with the webkit engine, and safari and the android browser use it. in safari you will get an error message so it s more easy to find the error :)

1 decade ago by Fooshi

Oh thank you for the Tip ! in fact i had an error in the console :
TypeError: 'undefined' is not a function (evaluating 'ig.$new('audio').canPlayType('audio/mpeg')')

then i have comments this line :
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);	
	}	

and the error has gone :) ... but i have still a blanck screen and no error displayed :(

1 decade ago by Fooshi

Sorry i have done a mistake in my response i have still the error in the console and i left : ig.main('#canvas', TotemGame, 60, 320, 480, 1);

1 decade ago by Fooshi

Biolab disaster does'nt work too on safari !?
then it's a bug of ImpactJs, my project must working on Android.

1 decade ago by Fooshi

My project doesnt still work both on android and safari with this console error log :

TypeError: 'undefined' is not a constructor (evaluating 'new Audio()')

Does someone have a solution ? Thank you
Page 1 of 1
« first « previous next › last »