Sorry to bother everyone but rushing to finish college assignment (FPS game) and can't figure out a problem. I have a sort of radar system running at bottom of screen which represents the position of every enemy on map. To represent an enemy on the radar i'm using a textured quad that has its renderqueue mode set to ortho. Every time the update method is called the quad is removed from the scenegraph and a new quad is draw in the new position to represent the updated position of an enemy.
However when I remove the quad , the new quad that is added appears in the very bottom left corner and not in the position that the old quad was rendered at. If i dont remove the quad and just keep added new quads over the originals the position remains correct on screen. However this is no good as it leaves a trail of textures quads instead of just one. Just wondering if there is some method that i'm missing each time the quad is removed or some method that is not necessary.
Here is the source code of the method to update the radar blip that represents the player.
private void updateRadar()
{
AlphaState as2 = display.getRenderer().createAlphaState();
as2.setBlendEnabled(true);
as2.setSrcFunction(AlphaState.SB_SRC_ALPHA);
as2.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA);
as2.setTestEnabled(false);
as2.setEnabled(true);
LightState ls = display.getRenderer().createLightState();
ls.setEnabled(false);
/**/
hudNode.detachChild(playerQuad); // remove original quad
//radarNode.detachAllChildren();
playerQuad = new Quad("playerQuad", 8f, 8f); // create new quad to add
playerQuad.getLocalRotation().set(0, 0, 0, 1);
float xPos = cam.getLocation().x / 5;
float yPos = cam.getLocation().z / 5;
playerQuad.getLocalTranslation().set(display.getWidth() - 420 + xPos, display.getHeight() - 530 + yPos, 0);
playerQuad.getLocalScale().set(1, 1, 1);
playerQuad.setRenderQueueMode(Renderer.QUEUE_ORTHO);
playerQuad.setRenderState(as2);
TextureState tsrad = display.getRenderer().createTextureState();
tsrad.setTexture(
TextureManager.loadTexture(JavaFPS.class.getResource("artwork/radarblue.png"),
Texture.MM_LINEAR_LINEAR,
Texture.FM_LINEAR)
);
tsrad.setEnabled(true);
playerQuad.setRenderState(tsrad);
playerQuad.setRenderState(ls);
playerQuad.updateRenderState();
hudNode.attachChild(playerQuad);
hudNode.updateRenderState();
}
Any suggestions / comments would be much appreciated
Thanks