I have created a game using LibGDX
and now want to use SPen SDK there. So, when I create SPenEventLibrary
and set listener it stops working. I get reaction from onTouchFinger
(I don't have the pen, that's why I use only this event), but when I try to propagate motion event to Stage
's events such as touchDown
and touchUp
- it doesn't work!
First of all I get view, because mSPenEventLibrary.setSPenTouchListener
requires it:
TearTissue.libGDXView = initializeForView(new TearTissue(), config);
Then I extend Stage
class:
protected SPenEventLibrary mSPenEventLibrary;
public class MyStage extends Stage{
public MyStage(float width, float height, boolean keepAspectRatio, SpriteBatch batch){
super(width, height, keepAspectRatio, batch);
final Stage localStage = this;
mSPenEventLibrary = new SPenEventLibrary();
mSPenEventLibrary.setSPenTouchListener(TearTissue.libGDXView, new SPenTouchListener() {
@Override
public boolean onTouchPenEraser(View arg0, MotionEvent arg1) {
return false;
}
@Override
public boolean onTouchPen(View arg0, MotionEvent arg1) {
return false;
}
@Override
public boolean onTouchFinger(View arg0, MotionEvent arg1) {
if(arg1.getAction()==MotionEvent.ACTION_DOWN){
localStage.touchDown((int)(arg1.getX()), (int)(arg1.getY()), 0, 0);
}
if(arg1.getAction()==MotionEvent.ACTION_UP){
localStage.touchUp((int)(arg1.getX()), (int)(arg1.getY()), 0, 0);
}
return true;
}
@Override
public void onTouchButtonUp(View arg0, MotionEvent arg1) {
}
@Override
public void onTouchButtonDown(View arg0, MotionEvent arg1) {
}
});
}
//DO SOME STUFF, THAT'S WHY I OVERRIDE IT
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
return super.touchDown(screenX, screenY, pointer, button);
}
@Override
public boolean touchDragged(int arg0, int arg1, int arg2) {
return super.touchDragged(arg0, arg1, arg2);
}
@Override
public boolean touchUp(int arg0, int arg1, int arg2, int arg3) {
return super.touchUp(arg0, arg1, arg2, arg3);
}
}
What am I doing wrong? Any help will be appreciated!