jPCT-AE - a 3d engine for Android > Support

How to change texture after pick up a object

(1/1)

hoangitk:
Dear all,

I would like to change the texture of picked object.
I have tried:

--- Code: ---.....
if (event.getAction() == MotionEvent.ACTION_UP) {

if (System.currentTimeMillis() - time < 1000) {
Object3D clickedObj = renderer.PickObj(xpos, ypos);

if (clickedObj != null) {
// set prevClickedObj for tracking
if(prevClickedObj == null || !clickedObj.equals(prevClickedObj)) {
prevClickedObj = clickedObj;
}

statusInfo.setText(clickedObj.getName());
clickedObj.setTexture("textureSelectedLocation");

} else {
// uncheck clicked object
if(prevClickedObj != null) {
prevClickedObj.setTexture("textureLocation");
}
}
}
....

--- End code ---

With purpose highlight a picked object.
But it is not effect.

Please kindly advise!

Thank you so much!

EgonOlsen:
Is clickedObject ever !=null? What does renderer.PickObj(xpos, ypos) do?

hoangitk:
Dear Mr.EgonOlsen,

I found out why.

Because I forgot changing texture name between "textureLocation" and "textureSelectedLocation".

Best regards!

Navigation

[0] Message Index

Go to full version