public bool initWithTarget(CCNode followedNode) { Debug.Assert(followedNode != null); m_pobFollowedNode = followedNode; m_bBoundarySet = false; m_bBoundaryFullyCovered = false; CCSize winSize = CCDirector.sharedDirector().getWinSize(); m_obFullScreenSize = new CCPoint(winSize.width, winSize.height); m_obHalfScreenSize = CCPointExtension.ccpMult(m_obFullScreenSize, 0.5f); return(true); }
/// <summary> /// Converts a Point to node (local) space coordinates. The result is in Points. /// treating the returned/received node point as anchor relative. /// @since v0.7.1 /// </summary> public CCPoint convertToNodeSpaceAR(CCPoint worldPoint) { CCPoint nodePoint = convertToNodeSpace(worldPoint); CCPoint anchorInPoints; if (CCDirector.sharedDirector().ContentScaleFactor == 1) { anchorInPoints = m_tAnchorPointInPixels; } else { anchorInPoints = CCPointExtension.ccpMult(m_tAnchorPointInPixels, 1 / CCDirector.sharedDirector().ContentScaleFactor); } return(CCPointExtension.ccpSub(nodePoint, anchorInPoints)); }
/// <summary> /// Converts a local Point to world space coordinates.The result is in Points. /// treating the returned/received node point as anchor relative. /// @since v0.7.1 /// </summary> public CCPoint convertToWorldSpaceAR(CCPoint nodePoint) { CCPoint anchorInPoints; if (CCDirector.sharedDirector().ContentScaleFactor == 1) { anchorInPoints = m_tAnchorPointInPixels; } else { anchorInPoints = CCPointExtension.ccpMult(m_tAnchorPointInPixels, 1 / CCDirector.sharedDirector().ContentScaleFactor); } CCPoint pt = CCPointExtension.ccpAdd(nodePoint, anchorInPoints); return(convertToWorldSpace(pt)); }
/// <summary> /// Converts a Point to world space coordinates. The result is in Points. /// @since v0.7.1 /// </summary> public CCPoint convertToWorldSpace(CCPoint nodePoint) { CCPoint ret; if (CCDirector.sharedDirector().ContentScaleFactor == 1) { ret = CCAffineTransform.CCPointApplyAffineTransform(nodePoint, nodeToWorldTransform()); } else { ret = CCPointExtension.ccpMult(nodePoint, CCDirector.sharedDirector().ContentScaleFactor); ret = CCAffineTransform.CCPointApplyAffineTransform(ret, nodeToWorldTransform()); ret = CCPointExtension.ccpMult(ret, 1 / CCDirector.sharedDirector().ContentScaleFactor); } return(ret); }
public bool init() { bool bRet = false; do { CCDirector director = CCDirector.sharedDirector(); if (director == null) { break; } contentSize = director.getWinSize(); // success bRet = true; } while (false); return(bRet); }
public virtual bool init() { bool bRet = false; do { CCDirector director = CCDirector.sharedDirector(); if (director == null) { break; } contentSize = director.getWinSize(); m_bIsTouchEnabled = false; m_bIsAccelerometerEnabled = false; bRet = true; } while (false); return(bRet); }
public bool initWithTarget(CCNode followedNode, CCRect rect) { Debug.Assert(followedNode != null); m_pobFollowedNode = followedNode; m_bBoundarySet = true; m_bBoundaryFullyCovered = false; CCSize winSize = CCDirector.sharedDirector().getWinSize(); m_obFullScreenSize = new CCPoint(winSize.width, winSize.height); m_obHalfScreenSize = CCPointExtension.ccpMult(m_obFullScreenSize, 0.5f); m_fLeftBoundary = -((rect.origin.x + rect.size.width) - m_obFullScreenSize.x); m_fRightBoundary = -rect.origin.x; m_fLeftBoundary = -rect.origin.y; m_fBottomBoundary = -((rect.origin.y + rect.size.height) - m_obFullScreenSize.y); if (m_fRightBoundary < m_fLeftBoundary) { // screen width is larger than world's boundary width //set both in the middle of the world m_fRightBoundary = m_fLeftBoundary = (m_fLeftBoundary + m_fRightBoundary) / 2; } if (m_fTopBoundary < m_fBottomBoundary) { // screen width is larger than world's boundary width //set both in the middle of the world m_fTopBoundary = m_fBottomBoundary = (m_fTopBoundary + m_fBottomBoundary) / 2; } if ((m_fTopBoundary == m_fBottomBoundary) && (m_fLeftBoundary == m_fRightBoundary)) { m_bBoundaryFullyCovered = true; } return(true); }
/// <summary> /// get the center vector values int points /// </summary> /// <param name="pCenterX"></param> /// <param name="pCenterY"></param> /// <param name="pCenterZ"></param> public void getCenterXYZ(out float pCenterX, out float pCenterY, out float pCenterZ) { pCenterX = m_fCenterX / CCDirector.sharedDirector().ContentScaleFactor; pCenterY = m_fCenterY / CCDirector.sharedDirector().ContentScaleFactor; pCenterZ = m_fCenterZ / CCDirector.sharedDirector().ContentScaleFactor; }
/// <summary> /// get the eye vector values in points /// </summary> /// <param name="pEyeX"></param> /// <param name="pEyeY"></param> /// <param name="pEyeZ"></param> public void getEyeXYZ(out float pEyeX, out float pEyeY, out float pEyeZ) { pEyeX = m_fEyeX / CCDirector.sharedDirector().ContentScaleFactor; pEyeY = m_fEyeY / CCDirector.sharedDirector().ContentScaleFactor; pEyeZ = m_fEyeZ / CCDirector.sharedDirector().ContentScaleFactor; }
private CCPoint convertToWindowSpace(CCPoint nodePoint) { CCPoint worldPoint = this.convertToWorldSpace(nodePoint); return(CCDirector.sharedDirector().convertToUI(worldPoint)); }