I have 2 objects on the screen:
static:
non-static:
non-static object moves randomly over the screen.
How do I know that non-static Object cross the "+" (static).
Both objects I draw by using followed code:
private void updateScreenData(float screenWidth, float screenHeight){
// takes screen Height and Width
this.mScreenWidth = (screenWidth > 0) ? screenWidth : 1f;
this.mScreenHeight = screenHeight;
wRatio = 10f/mScreenWidth;
hRatio = mScreenHeight/10f;
}
protected void drawTarget(GL10 gl){
gl.glPushMatrix();
try {
float transx = shiftX + (wRatio * (x));
float transy = shiftY +(mScreenHeight*wRatio) - (wRatio * (y)) - 1/hRatio;
gl.glTranslatef(transx, transy, 0.0f);
//########### draw ##############
gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, floatBufferArray[mFrame]);
//update();
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
//###############################
} catch (NullPointerException e) {
}
gl.glPopMatrix();
}
public void loadTextures(GL10 gl) {
Log.e(LOG_TAG, "loadTextures");
InputStream is;
is = mContext.getResources().openRawResource(_SRC);
Bitmap bitmap = BitmapFactory.decodeStream(is);
try {
is.close();
is = null;
} catch (IOException e) {
}
gl.glGenTextures(TEXTURE_COUNT, textures, 0);
gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
bitmap.recycle();
}
Any ideas?
What do I need to compare in both Objects?
[EDIT]
I see my question is not so clear, so i'll try once more.
Since my cross image stays at the middle of screen (screenWidth/2
and screenWidth/2
) I know the coordinates, it do not change. But second Object changes.
How can I fetch out coordinates (aka x,y) from dynamic object?