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 riemaxi

Hi guys

this is the code for one of my entities:

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

    EntityXyz = ig.Entity.extend({
        
        size: {x:86, y:145},
        
        init: function(x, y, settings) {
            // Call the parent constructor
            this.parent(x, y, settings);
            
            this.animSheet = new ig.AnimationSheet( 'media/xyz.png');
        }
    });
});

When using wm, the entity Xyz shows up properly in the menu, but when I add it to a layer, then only a border with the name xyz in the upper left corner is shown. No image is shown.

Of course, when I run the game, the entity is not there (or can not be seen)

Any idea?

1 decade ago by delly

maybe because you don't have any animation on your entity ?

try to call addAnim first:

this.addAnim( 'idle', 1, [0] );

1 decade ago by riemaxi

Hi delly
Thanks for your answer, but I already tried that and now I tried it again ... and it is not working.

This is the code now. This time I use the same practice, I initialize the animSheet in the constructor:

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

EntityXyz = ig.Entity.extend({

	size: {x:86, y:145},
	animSheet : new ig.AnimationSheet( 'media/xyz.png'),

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

});

});

.. and it is NOT working ...

As you can see this is a very basic entity, no reason for troubles.

1 decade ago by alexandre

I had similar troubles this morning caused by my image size not matching the size property of its corresponding entity. So, in that order:

1. ensure that the dimensions of xyz.png are indeed 86 by 145. I was off by 1 pixel and the image failed to show on canvas.

2. if #1 didn't help, run your game with debug mode on, and in the debug panel, select the Entities tab and check the "Show collision boxes" checkbox. Do you see anything?

Alex

1 decade ago by dominic

The constructor for ig.AnimationSheet expects the width and height of an animation frame as the 2nd and 3rd parameter. E.g. if an animation frame is 16x16 pixels:
animSheet : new ig.AnimationSheet( 'media/xyz.png', 16, 16 ),
Page 1 of 1
« first « previous next › last »