public void mouseDragged(CCMouseEvent theEvent) { int x = theEvent.x(); int y = theEvent.y(); CCMouseButton button = theEvent.button(); _mouseX = x; _mouseY = y; _mouseButton = button; if (isInside(x, y)) { // if mouse is over the object if (!_mouseOver) { // if wasn't over previous frame // onPress(x, y); // // call onPress - maybe not _mouseOver = true; // update flag } onDragOver(x, y, button); // and trigger onDragOver } else { if (_mouseOver) { // if mouse is not over the object, but the flag is true (From previous // frame) onRollOut(); // call onRollOut _mouseOver = false; // update flag } if (_mouseDown) { onDragOutside(x, y, button); } } }
public void mouseReleased(CCMouseEvent theEvent) { int x = theEvent.x(); int y = theEvent.y(); CCMouseButton button = theEvent.button(); _mouseX = x; _mouseY = y; _mouseButton = button; if (isInside(x, y)) { onRelease(x, y, button); } else { if (_mouseDown) onReleaseOutside(x, y, button); } _mouseDown = false; }
public void mousePressed(CCMouseEvent theEvent) { int x = theEvent.x(); int y = theEvent.y(); CCMouseButton button = theEvent.button(); _mouseX = x; _mouseY = y; _mouseButton = button; if (isInside(x, y)) { // if mouse is over if (!_mouseDown) { // if wasn't down previous frame onPress(x, y, button); // call onPress _mouseDown = true; // update flag } } else { // if mouse is not over onPressOutside(x, y, button); } }
public void mouseMoved(CCMouseEvent theEvent) { int x = theEvent.x(); int y = theEvent.y(); CCMouseButton button = theEvent.button(); _mouseX = x; _mouseY = y; if (isInside(x, y)) { // if mouse is over the object if (!_mouseOver) { // if wasn't over previous frame onRollOver(x, y); // call onRollOver _mouseOver = true; // update flag } onMouseMove(x, y); // and trigger onMouseMove } else if (_mouseOver) { // if mouse is not over the object, but the flag is true (From previous // frame) onRollOut(); // call onRollOut _mouseOver = false; // update flag } }