public override void startWithTarget(CCNode target) { base.startWithTarget(target); m_sConfig.controlPoint_1 = CCPointExtension.ccpSub(m_sConfig.controlPoint_1, m_startPosition); m_sConfig.controlPoint_2 = CCPointExtension.ccpSub(m_sConfig.controlPoint_2, m_startPosition); m_sConfig.endPosition = CCPointExtension.ccpSub(m_sConfig.endPosition, m_startPosition); }
public override void ccTouchEnded(CCTouch touch, CCEvent eve) { CCPoint location = touch.locationInView(touch.view()); CCPoint convertedLocation = CCDirector.sharedDirector().convertToGL(location); CCPoint pos = new CCPoint(0, 0); if (m_background != null) { pos = m_background.convertToWorldSpace(new CCPoint(0, 0)); } m_emitter.position = CCPointExtension.ccpSub(convertedLocation, pos); }
public int check_for_error(CCPoint p1, CCPoint p2, CCPoint p3, CCPoint p4, float s, float t) { // the hit point is p3 + t * (p4 - p3); // the hit point also is p1 + s * (p2 - p1); CCPoint p4_p3 = CCPointExtension.ccpSub(p4, p3); CCPoint p4_p3_t = CCPointExtension.ccpMult(p4_p3, t); CCPoint hitPoint1 = CCPointExtension.ccpAdd(p3, p4_p3_t); CCPoint p2_p1 = CCPointExtension.ccpSub(p2, p1); CCPoint p2_p1_s = CCPointExtension.ccpMult(p2_p1, s); CCPoint hitPoint2 = CCPointExtension.ccpAdd(p1, p2_p1_s); // Since float has rounding errors, only check if diff is < 0.05 if ((Math.Abs(hitPoint1.x - hitPoint2.x) > 0.1f) || (Math.Abs(hitPoint1.y - hitPoint2.y) > 0.1f)) { Debug.WriteLine("ERROR: (%f,%f) != (%f,%f)", hitPoint1.x, hitPoint1.y, hitPoint2.x, hitPoint2.y); return(1); } return(0); }
public override void startWithTarget(CCNode target) { base.startWithTarget(target); m_startPosition = target.position; m_delta = CCPointExtension.ccpSub(m_endPosition, m_startPosition); }