ChaseCamera

I can’t seem to get chase camera rotation to work on android. Setting UseMultiTouch to true disables simulation of mouse events. If I setSimulateMouse(true) the camera can be rotated by dragging again. The problem with this is I’m using a joystick to move the character and it doesn’t distinguish these events from other screen events.

Example: If I’m moving the character with the joystick and at the same time drag the camera it might interpret this as a zoom action. It may also use the joystick event move direction as the move direction of the camera.

My main question would be am I missing something to enable chase camera rotation on an Android device while using tonegodGUI?

Actually, I have no clue. I haven’t tested this with the chase cam. I in the midst of updating stuff in the library, so give me a bit to look into this.

No rush. I looked into this more and it appears as though the ChaseCamera is not setup to work with touch events. Since using multitouch with Screen disables mouse simulation there are no usable events for the ChaseCamera.

@Aquanaut81 said: No rush. I looked into this more and it appears as though the ChaseCamera is not setup to work with touch events. Since using multitouch with Screen disables mouse simulation there are no usable events for the ChaseCamera.

Ah… it likely wouldn’t take much to modify the existing ChaseCam to work with touch events as apposed to simulated mouse. If I recall correctly, each touch event has an ID, just ensure the ID’s match before applying the event info to the cam. You can find the necissary code (if you want to cut & paste) within Screen.class… I believe.

Heh… not sure what made me think of this so far after answering it.

All gui elements should consume events by default, so anything that is passed through to the cam could be considered fair game. Just grab and store the ID and watch for the next event that comes through with the same ID, etc, etc.

EDIT: I would also consider setting up pinch for zooming by default

P.S. Let me know if you decide to do this. I’d love to play around with the results!

I might try looking into this some but as I still consider myself a newbie as far as JME and game programming goes, so it might take me a little while. That and the fact I only get in about ~2 hrs of work in on it a day during the week.

On a side note I pulled down your code and have been making somewhat small modifications to it to suit my ui needs. Such as an image for the tab button, being able to set the height of the tab slider, disable the slider nav buttons, etc… Also a change or two so I could modify the knob image used without having to create my own theme. It might not be the clean or complete but if you want to have a look at that let me know.

Okay. I have got it working. Might not be the best way of going about it but it is something

In ChaseCamera add the following:

Add following to registerWithInput(…)

[java]inputManager.addMapping(“ALL_TOUCH_INPUT”, new TouchTrigger(TouchInput.ALL));
inputManager.addListener(this, “ALL_TOUCH_INPUT”);[/java]

Add TouchListener implementation.

[java]
protected boolean touchZooming = false;

public void onTouch(String name, TouchEvent event, float tpf) {
switch (event.getType()) {
case DOWN:
if(!touchZooming)
{
canRotate = true;
}
break;
case MOVE:
if(!touchZooming)
{
rotateCamera(event.getDeltaX() / 1024f);
vRotateCamera(event.getDeltaY() / 1024f);
}
break;
case UP:
canRotate = false;
break;
case SCALE_START:
if(!canRotate)
{
touchZooming = true;
}
break;
case SCALE_MOVE:
if(touchZooming)
{
zoomCamera(event.getDeltaScaleSpan() / 100f);
}
break;
case SCALE_END:
touchZooming = false;
break;
}
}
[/java]

In Screen.java - OnTouchEvent(…)

[java]
case SCALE_MOVE:
case SCALE_START:
case SCALE_END:
for (Integer key : eventElements.keySet()) {
if (key == evt.getPointerId()) {
evt.setConsumed();
}
}
break;
[/java]

1 Like

Now I have to figure out why when I hit the power button on my phone, shutting the screen off, that when I unlock the screen it re-enables simulation of mouse events.