コード例 #1
0
 @Override
 public void mousePressed(CCMouseEvent theMouseEvent) {
   for (CCVector2f myControlPoint : _myControlPoints) {
     if (myControlPoint.distance(theMouseEvent.position()) < 10) {
       _mySelectedPoint = myControlPoint;
       return;
     }
   }
   _mySelectedPoint = null;
 }
コード例 #2
0
  @Override
  public void mouseDragged(CCMouseEvent theMouseEvent) {
    if (_mySelectedPoint != null) {
      _mySelectedPoint.set(theMouseEvent.position());
    }

    _myControlPoint1.x = CCMath.max(_myPoint1.x, _myControlPoint1.x);
    _myControlPoint2.x = CCMath.max(_myControlPoint1.x, _myControlPoint2.x);
    _myPoint2.x = CCMath.max(_myControlPoint2.x, _myPoint2.x);
  }
コード例 #3
0
  /**
   * Returns the center of this area
   *
   * @return
   */
  public CCVector2f center() {
    CCVector2f d = new CCVector2f(0.0f, 0.0f);
    int c = 0;

    for (CCConnectedPixelRow myPixelRow : _myConnectedPixelRows) {
      d.add(myPixelRow.center());
      c++;
    }
    return d.scale(1f / c);
  }