|
@@ -36,6 +36,7 @@ import com.jme3.app.SimpleApplication;
|
|
|
import com.jme3.input.RawInputListener;
|
|
|
import com.jme3.input.event.*;
|
|
|
import com.jme3.math.FastMath;
|
|
|
+import com.jme3.math.Vector2f;
|
|
|
import com.jme3.system.AppSettings;
|
|
|
import com.jme3.texture.Texture;
|
|
|
import com.jme3.texture.Texture2D;
|
|
@@ -47,8 +48,6 @@ public class TestSoftwareMouse extends SimpleApplication {
|
|
|
|
|
|
final private RawInputListener inputListener = new RawInputListener() {
|
|
|
|
|
|
- private float x = 0, y = 0;
|
|
|
-
|
|
|
@Override
|
|
|
public void beginInput() {
|
|
|
}
|
|
@@ -63,8 +62,8 @@ public class TestSoftwareMouse extends SimpleApplication {
|
|
|
}
|
|
|
@Override
|
|
|
public void onMouseMotionEvent(MouseMotionEvent evt) {
|
|
|
- x += evt.getDX();
|
|
|
- y += evt.getDY();
|
|
|
+ float x = evt.getX();
|
|
|
+ float y = evt.getY();
|
|
|
|
|
|
// Prevent mouse from leaving screen
|
|
|
AppSettings settings = TestSoftwareMouse.this.settings;
|
|
@@ -107,6 +106,12 @@ public class TestSoftwareMouse extends SimpleApplication {
|
|
|
cursor.setWidth(64);
|
|
|
cursor.setHeight(64);
|
|
|
guiNode.attachChild(cursor);
|
|
|
+ /*
|
|
|
+ * Position the software cursor
|
|
|
+ * so that its upper-left corner is at the hotspot.
|
|
|
+ */
|
|
|
+ Vector2f initialPosition = inputManager.getCursorPosition();
|
|
|
+ cursor.setPosition(initialPosition.x, initialPosition.y - 64f);
|
|
|
|
|
|
inputManager.addRawInputListener(inputListener);
|
|
|
|