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,
I want to create a game like a "scratch card". I have two image and when the cursor of the mouse is pressed i want the area of the mouse discover the background image.
Then i have create an instance entity for the firt image and a game instance like this :

ig.module(
	'game.main'
)
.requires(
	'impact.entity',
	'impact.game',
	'impact.font',
	'impact.image',
	'impact.map',
	'impact.input',
	'impact.animation'
)
.defines(function(){
	
	FirstEntity	= ig.Entity.extend({
		size		:	{x:320, y:480},
		animSheet	: new ig.AnimationSheet('media/fond.jpg',320,480),
		init		: function(x,y,settings){
			this.addAnim('idle',0.1,[0]);
			this.parent(x,y,settings);
		}
		
	});
	
	// Classe du Jeu
	TotemGame	= ig.Game.extend({
		clearColor	: '#FFF',
		euro1		: new ig.Image('media/euro1.png'),
		background	: new ig.Image('media/fond.jpg'),		
		init		: function(){	
			
			ig.input.bind(ig.KEY.MOUSE1, 'scratch');							// Ecouteur de la souris
			
			this.euro1.draw(0,0);	
				
		},
		update		: function(){
			if(ig.input.state('scratch'))
			{
				console.log('X :'+ig.input.mouse.x+' Y :'+ig.input.mouse.y);
			}
		},
		draw		: function(){				
		}
	});
	ig.main('#canvas', TotemGame, 60, 320, 480, 1);	
});



Then i don't know how to load the entity on the game and to change the alpha of this entity.

1 decade ago by Fooshi

I have added this.spawnEntity(FirstEntity,0,0); to the init function of totemgame and the entity doesn't load too :-/
Page 1 of 1
« first « previous next › last »