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 RationalGaze

Hi everyone,

My problem is simple as that : when i choose my entity from the displayed list in Weltmeister, its just represented by an empty square with yellow borderlines, and the entity's name on it. It doesn't show any sprites/images, and even if i launch the game it just doesnt show up. Any idea ?

Thanks :)

1 decade ago by UteEffacht

Have you defined a sprite sheet for your entity and set the current animation? If you did, the code of your entity would help.

Ah, and I dont think its necessary to post your question in two categories at the same time...

1 decade ago by RationalGaze

Here's my code :

ig.module(
	'game.entities.cubeplayer'
)
.requires(
	'impact.entity'
)
.defines(function(){

EntityCubeplayer = ig.Entity.extend({

	size: {x:16, y:16},
	collides: ig.Entity.COLLIDES.FIXED,

	animSheet: new ig.AnimationSheet( 'media/cube.png', 16, 16 ),


	update: function() {

		if( ig.input.state('left') ) {
			this.vel.x = -100;
		}
		else if( ig.input.state('right') ) {
			this.vel.x = 100;
		}
		else {
			this.vel.x = 0
		}
	
		this.parent();

	}
		
});

});

and then i tried to add

init: function( x, y, settings ) {
		this.parent( x, y, settings );
		
		this.addAnim( 'idle', 1, [0] );
	}

and here' the final code :

ig.module(
	'game.entities.cubeplayer'
)
.requires(
	'impact.entity'
)
.defines(function(){

EntityCubeplayer = ig.Entity.extend({

	size: {x:16, y:16},
	collides: ig.Entity.COLLIDES.FIXED,

	animSheet: new ig.AnimationSheet( 'media/cube.png', 16, 16 ),

	init: function( x, y, settings ) {
		this.parent( x, y, settings );
		
		this.addAnim( 'idle', 1, [0] );
	},

	update: function() {

		if( ig.input.state('left') ) {
			this.vel.x = -100;
		}
		else if( ig.input.state('right') ) {
			this.vel.x = 100;
		}
		else {
			this.vel.x = 0
		}
	
		this.parent();

	}


	
		
});


but it doesn't work :/


P.S : Yes i'm sorry i just thought the other forum was simply deserted so i posted this thread here.

1 decade ago by RationalGaze

ITS GOOOOOOOOOOOOD ! Thanks Ute :)

1 decade ago by tarrent

Hi RationalGaze, you seem to have forgotten to set the current animation (this.currentAnim) in the init() or anlywhere else.

init: function( x, y, settings ) {
  this.parent( x, y, settings );
  this.addAnim( 'idle', 1, [0] );
  
  // set current animation here
  this.currentAnim = this.anims.idle;
}

I hope this helps ;)
Page 1 of 1
« first « previous next › last »