klenwell information services : PlaynListener

Wiki source for PlaynListener


Show raw source

=====PlayN Listener Patters=====
return to DevPlayN

====Pointer General Listener====
%%(java)
PlayN.pointer().setListener(new Pointer.Listener() {
@Override
public void onPointerStart(Pointer.Event event) {
PlayN.log().info("Pointer start: " + event);
PlayN.log().info("is touch? " + event.isTouch());
}

@Override
public void onPointerEnd(Pointer.Event event) {
PlayN.log().info("Pointer end: " + event);
}

@Override
public void onPointerDrag(Pointer.Event event) {
PlayN.log().info("Pointer drag: " + event);
}
});
%%


====Pointer Layer Listener====
%%(java)
ImageLayer myImageLayer = myImage.layer();

myImageLayer.addListener(new Pointer.Listener() {
@Override
public void onPointerStart(Pointer.Event event) {
PlayN.log().info("Pointer start: " + event);
PlayN.log().info("is touch? " + event.isTouch());
}

@Override
public void onPointerEnd(Pointer.Event event) {
PlayN.log().info("Pointer end: " + event);
}

@Override
public void onPointerDrag(Pointer.Event event) {
PlayN.log().info("Pointer drag: " + event);
}
});
%%