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

10 years ago by AndreasElia

Hello,

I'm currently having a problem with some GUI entities, they seem to stutter whenever the camera/screen moves.

http://i.imgur.com/txYwxlQ.gif

Thanks,
Andreas

10 years ago by AndreasElia

My bad, forgot to post source code.

http://pastie.org/private/svqycgti3vrq2neuyt5k9g

10 years ago by TC

Replace update method with below

update: function() {
	this.pos.x = this.posBar.x;
	this.pos.y = this.posBar.y;
	
	if( this.currentAnim ) {
		this.currentAnim.update();
	}
}

By removing this.parent() we are ignoring the games entity positioning and leaving it in a fixed position on the screen which is what you are trying to achieve I believe.

As we have removed this.parent(), we have added in this.curentAnim.update() to ensure the animation still updates.

I'm not sure why you have this.posBar, why not just set this.pos.x and this.pos.y to those values in the first place?

TC

10 years ago by AndreasElia

Thanks for your help but that's a little bit of a step back from what I wanted to achieve. I currently have a player that can move in a "top down" fashion but wish the "slot" GUI entity to stick to the cameras position so that it is constantly on screen and not fixed to the actual map. posBar was from testing and lazyness, hopefully it isn't too confusing.

http://i.imgur.com/Gq5WRIh.gif

GIF using your suggestion, fixes the slots to the map.

10 years ago by Joncom

You can simply draw the entity where you want.

// Assuming you want the entity drawn 10 pixels off the top left of canvas...
pos: { 
    x: 10,
    y: 10
},
draw: function() {
    /* Don't call this.parent(); */
    this.currentAnim.draw(this.pos.x, this.pos.y);
}

10 years ago by AndreasElia

Thank you very much Joncom, that worked a charm.
Page 1 of 1
« first « previous next › last »