@Override public void mousePressed(CCMouseEvent theMouseEvent) { for (CCVector2f myControlPoint : _myControlPoints) { if (myControlPoint.distance(theMouseEvent.position()) < 10) { _mySelectedPoint = myControlPoint; return; } } _mySelectedPoint = null; }
@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); }
/** * 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); }