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 ShawnSwander

I can't just give it an invisible animation frame because mouse-over actions would still work.

This is to simulate entities that you can't see because they are invisible, hidden, or around the corner/ in the shadows etc.

What I'm doing now isn't working
This snippet is for the entity is on a tile that is triggered to be set on a tile the player cannot see
			if(ig.game.backgroundMaps[4].getTile(this.pos.x,this.pos.y)==0){
				this.currentAnim = this.hidden;
				this.hidden=null;
			}
			if(ig.game.backgroundMaps[4].getTile(this.pos.x,this.pos.y)==1){
				this.hidden = this.currentAnim
				this.currentAnim = null
			}

1 decade ago by lazer

Not sure if this is relevant to what you need to achieve, but why not resposition the entities out of sight with pos.x and pos.y when they need to be hidden?

1 decade ago by ShawnSwander

I do that for some things but at times their position is relevant to my coding. For example hiding an entity because he has a spell on him that makes him invisible unless he is next to you or hiding an entity because his position is in a tile that cannot be seen. If I were to move him off the map and the entity AI wanted to move it would cause problems. Its a good idea and it migth be on the right track to save the position or set the position to position*-1 and change it back for calculations. It would be nice if the entity just had a hidden property I could write.

1 decade ago by lazer

Yeah that's what I was thinking, is if you could save the last coordinates before moving to the preset hidden coordinates and check against those. But I see what you mean, it certainly doesn't sound like the most streamlined option.

Can you not create a "hidden" attribute for these entities and disable mouse actions on them if this.hidden is true, then do the invisible animation frame thing? You could also change their collision temporarily while you're at it.

1 decade ago by ShawnSwander

For what its worth the best method I've come up with is pos.x=pos.x*-1 and while its hidden check against pos.x*-1 rather than its pos.x

this moves it off the map but allows it to interact as if it weren't. This is what I do for doors but Its not optimal.

1 decade ago by StuartTresadern

I am probably missing the point but cant you just override draw for the entities and then check against a hidden flag, if not hidden then call this.parent(). Then check against the hidden flag for any other interactions etc that should not happen while the entity is in its hidden state.
Page 1 of 1
« first « previous next › last »