1 decade ago
by Dejan
Is there a way to draw an entity over all other layers (including all layers which are over the entity layer)?
Hello Dejan,
try
this.zIndex = number;
“ … Drawing order. Entities with a higher .zIndex will get drawn last. …."
Reference:
http://impactjs.com/documentation/class-reference/entity#zindex
Hope that helps.
nightbyter
1 decade ago
by Dejan
Hello nightbyter,
first thanks for the reply.
Unfortunatly this is not what i was looking for. With the Z index I can only put one entity over all other entities. But what I want to do is to draw one entity over the highest Weltmeister layer. You could imagine my layers being like this:
foreground layer
entity layer
background layer 2
background layer 1
So using the z index would only bring me on top of the entity layer. But what I want is one entity being over the foreground layer.
Still thanks for your help :)
See this post
Entity that's "always on top"
EDIT: @Joncom you beat me to it
1 decade ago
by Dejan
Thanks you two, that's exactly what I was looking for
-
Just a little question. If I'm trying to draw it it's telling me that my special entity is undefined. So it would be nice if one of you could tell me if I understood everything correctly.
So first I need to set up my entity like this
ig.module(
'game.entities.npc.test'
)
.requires(
'impact.entity'
)
.defines(function(){
EntityTest = ig.Entity.extend({
animSheet: new ig.AnimationSheet( 'media/test.png', 239, 221 ),
size: {x: 239, y:221},
offset: {x: 0, y: 0},
init: function( x, y, settings ) {
this.parent( x, y, settings );
this.addAnim( 'idle', 1, [0] );
ig.game.test = this;
},
update: function() {
this.parent();
},
draw: function( reallyDraw ) {
if( reallyDraw ) {
this.parent();
}
},
});
});
and then I need to draw my entity in the draw function with
this.test.draw( true );
instead of
ig.game.spawnEntity( EntityTest, 0, 0);
So what am I missing? Or did i misunderstood something?
You need to modify draw in your entity, and in main.js
this.test.draw(true) should come after this.parent(); in main.js (your Game)
It means all draws will be done and only then will main.js execute your special entity draw
// In your Entity
init: function( x, y, settings ) {
this.parent( x, y, settings );
// save a reference to this entity on your game
ig.game.specialEntity = this;
},
draw: function( reallyDraw ) {
// Only draw when the 'reallyDraw' param is true,
// so it ignores the "normal" draw call
if( reallyDraw ) {
this.parent();
}
}
// In your Game
draw: function() {
// Draw all background maps and entities
this.parent();
// Call draw() on your special entity with the extra
// parameter added
this.specialEntity.draw( true );
}
1 decade ago
by Dejan
Thanks, I now found what was going on. The entity which I actually wanted to display was my complete chatbox + all the text which is always updating itself. The problem was that it was only loading for 1 frame and then disappearing.
After realizing that I managed to fix that. But now the text isn't updating itself anymore and becouse of that not showing up at all.
Quite unfortunate that it seems to be working with all entities except for the one I need it to.
Anyways thaks for the help it definitifly made be get closer to solving the problem
edit: everything fixed by now, thanks for the help again
Page 1 of 1
« first
« previous
next ›
last »