コード例 #1
0
  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);
      }
    }
  }
コード例 #2
0
  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;
  }
コード例 #3
0
  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);
    }
  }
コード例 #4
0
  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
    }
  }