
/**@defCCRANDOM_MINUS1_1 returnSarandomfloatbetween-1and1 返回一个随机漂浮在-1和1之间的随机数*/ #defineCCRANDOM_MINUS1_1()((2.0f*((float)rand()/RAND_MAX))-1.0f) /**@defCCRANDOM_0_1 returnSarandomfloatbetween0and1 返回一个随机漂浮在0和1之间的随机数 */ #defineCCRANDOM_0_1()((float)rand()/RAND_MAX) /**@defCC_degrees_TO_radians convertsdegreestoradians 将度转换为弧度 */ #defineCC_degrees_TO_radians(__ANGLE__)((__ANGLE__)*0.01745329252f)//PI/180 /**@defCC_radians_TO_degrees convertsradianstodegrees 将弧度转换成度 */ #defineCC_radians_TO_degrees(__ANGLE__)((__ANGLE__)*57.29577951f)//PI*180 ************************************************************************************* /**HelpermacrothatcreatesaVec2 @returnVec2 @sincev0.7.2 */ CC_DEPRECATED_ATTRIBUTE inline Vec2ccp( float x, y) { return Vec2(x,y); @H_419_107@} /**Returnsoppositeofpoint. @returnVec2 @sincev0.7.2 @deprecatedpleaseuseVec2::-,forexample:-v1 */ static Vec2 ccpNeg( const Vec2&v) { -v; } /**Calculatessumoftwopoints. @returnVec2 @sincev0.7.2 @deprecatedpleaseuseVec2::+,forexample:v1+v2 */ Vec2 ccpAdd( Vec2&v1, Vec2&v2) { v1+v2; } /**Calculatesdifferenceoftwopoints. @returnVec2 @sincev0.7.2 */ Vec2 ccpsub( Vec2&v2) { v1-v2; } /**ReturnspointmultiplIEdbygivenfactor. @returnVec2 @sincev0.7.2 @deprecatedpleaseuseVec2::*,forexample:v1*v2 */ Vec2 ccpMult( Vec2&v,153)!important">const s) { v*s; } /**CalculatesmIDpointbetweentwopoints. @returnVec2 @sincev0.7.2 @deprecatedpleaseuseitlike(v1+v2)/2.0f */ Vec2 ccpMIDpoint( Vec2&v2) { v1.getMIDpoint(v2); } /**Calculatesdotproductoftwopoints. @returnfloat @sincev0.7.2 */ @H_626_301@inline float ccpDot( Vec2&v2) { v1.dot(v2); } /**Calculatescrossproductoftwopoints. @returnfloat @sincev0.7.2 */ float ccpCross( Vec2&v2) { v1.cross(v2); } /**Calculatesperpendicularofv,rotated90degreescounter-clockwise--cross(v,perp(v))>=0 @returnVec2 @sincev0.7.2 */ Vec2 ccpPerp( Vec2&v) { v.getPerp(); } @returnVec2 @sincev0.7.2 */ Vec2 ccpRPerp( Vec2&v) @H_468_403@{ v.getRPerp(); } /**Calculatestheprojectionofv1overv2. @returnVec2 @sincev0.7.2 */ Vec2 ccpProject( Vec2&v2) { v1.project(v2); @H_502_440@} /**Rotatestwopoints. @returnVec2 @sincev0.7.2 */ Vec2 ccpRotate( Vec2&v2) { v1.rotate(v2); } /**Unrotatestwopoints. @returnVec2 @sincev0.7.2 */ Vec2 ccpunrotate( Vec2&v2) { v1.unrotate(v2); @H_313_502@} /**CalculatesthesquarelengthofaVec2(notcallingsqrt()) @returnfloat @sincev0.7.2 */ float ccpLengthSQ( Vec2&v) { v.getLengthSq(); } /**Calculatesthesquaredistancebetweentwopoints(notcallingsqrt()) @returnfloat @sincev1.1 */ float ccpdistanceSQ( Vec2p1,monospace!important; Font-size:1em!important; min-height:inherit!important; color:black!important">Vec2p2) @H_301_560@{ (p1-p2).getLengthSq(); } /**Calculatesdistancebetweenpointanorigin @returnfloat @sincev0.7.2 */ ccpLength( Vec2&v) { v.getLength(); } /**Calculatesthedistancebetweentwopoints @returnfloat @sincev0.7.2 */ ccpdistance( Vec2&v2) { v1.getdistance(v2); } /**ReturnspointmultiplIEdtoalengthof1. @returnVec2 @sincev0.7.2 */ Vec2ccpnormalize( Vec2&v) { v.getnormalized(); } /**Convertsradianstoanormalizedvector. 将弧度转换为归一化向量。 @returnVec2 @sincev0.7.2 */ Vec2ccpForAngle( a) { Vec2::forAngle(a); } /**Convertsavectortoradians. 向量转换为弧度。 @returnfloat @sincev0.7.2 */ ccpToAngle( Vec2&v) { v.getAngle(); } /**Clampapointbetweenfromandto. @sincev0.99.1 */ Vec2ccpClamp( Vec2&p,monospace!important; Font-size:1em!important; min-height:inherit!important; color:black!important">Vec2&from,monospace!important; Font-size:1em!important; min-height:inherit!important; color:black!important">Vec2&to) { p.getClampPoint(from,to); } /**QuicklyconvertSizetoaVec2 @sincev0.99.1 @H_419_752@*/ Vec2ccpFromSize( Size&s) { Vec2(s); } /**Runamathoperationfunctiononeachpointcomponent *absf,fllorf,ceilf,roundf *anyfunctionthathasthesignature:floatfunc(float); *Forexample:let'strytotakethefloorofx,y *ccpCompOp(p,floorf); @sincev0.99.1 */ Vec2ccpCompOp( (*opFunc)( )) { p.compOp(opFunc); } /**linearInterpolationbetweentwopointsaandb @returns Alpha==0?a Alpha==1?b otherwiseavaluebetweena..b @sincev0.99.1 */ Vec2ccpLerp( Vec2&a,monospace!important; Font-size:1em!important; min-height:inherit!important; color:black!important">Vec2&b,monospace!important; Font-size:1em!important; min-height:inherit!important; color:black!important">Alpha) { a.lerp(b,Alpha); } /**@returnsifpointshavefuzzyequalitywhichmeansequalwithsomedegreeofvariance. @sincev0.99.1 */ bool ccpFuzzyEqual( variance) { a.fuzzyEquals(b,variance); } /**MultiplIEsaandbcomponents,a.x*b.x,a.y*b.y @returnsacomponent-wisemultiplication @sincev0.99.1 */ Vec2ccpCompMult( Vec2&b) { Vec2(a.x*b.x,a.y*b.y); } /**@returnsthesignedangleinradiansbetweentwovectordirections @sincev0.99.1 */ ccpAngleSigned( Vec2&b) { a.getAngle(b); } /**@returnstheangleinradiansbetweentwovectordirections @sincev0.99.1 */ ccpAngle( Vec2&b) { a.getAngle(b); } /**RotatesapointcounterclockwisebytheanglearoundAPIvot @paramvisthepointtorotate @parampivotisthepivot,naturally @paramangleistheangleofrotationcwinradians @returnstherotatedpoint @sincev0.99.1 */ Vec2ccpRotateByAngle( Vec2&pivot,monospace!important; Font-size:1em!important; min-height:inherit!important; color:black!important">angle) { v.rotateByAngle(pivot,angle); } /**Ageneralline-lineintersectiontest @paramp1 isthestartpointforthefirstlineP1=(p1-p2) @paramp2 istheendpointforthefirstlineP1=(p1-p2) @paramp3 isthestartpointforthesecondlineP2=(p3-p4) @paramp4 istheendpointforthesecondlineP2=(p3-p4) @params istherangeforahitpointinP1(pa=p1+s*(p2-p1)) @paramt istherangeforahitpointinP3(pa=p2+t*(p4-p3)) @returnbool indicatingsuccessfulintersectionofaline notethattotrulytestintersectionforsegmentswehavetomake surethats&tlIEwithin[0..1]andforrays,makesures&t>0 thehitpointisp3+t*(p4-p3); thehitpointalsoisp1+s*(p2-p1); @sincev0.99.1 */ ccplineIntersect( Vec2&p1,monospace!important; Font-size:1em!important; min-height:inherit!important; color:black!important">Vec2&p2, Vec2&p3,monospace!important; Font-size:1em!important; min-height:inherit!important; color:black!important">Vec2&p4, *s,monospace!important; Font-size:1em!important; min-height:inherit!important; color:black!important">*t) { Vec2::islineIntersect(p1,p2,p3,p4,s,t); } /* ccpsegmentIntersectreturnstrueifSegmentA-BintersectswithsegmentC-D @sincev1.0.0 */ CC_DEPRECATED_ATTRIBUTE ccpsegmentIntersect( Vec2&A,153)!important">const Vec2&B,monospace!important; Font-size:1em!important; min-height:inherit!important; color:black!important">Vec2&C,monospace!important; Font-size:1em!important; min-height:inherit!important; color:black!important">Vec2&D) { Vec2::isSegmentIntersect(A,B,C,D); } /* ccpIntersectPointreturnstheintersectionpointoflineA-B,C-D @sincev1.0.0 */ CC_DEPRECATED_ATTRIBUTE Vec2ccpIntersectPoint( Vec2& B,monospace!important; Font-size:1em!important; min-height:inherit!important; color:black!important">Vec2&D) { Vec2::getIntersectPoint(A,D); } Vec2CCPointMake( y) { } SizeCCSizeMake( wIDth,monospace!important; Font-size:1em!important; min-height:inherit!important; color:black!important">height) { Size(wIDth,height); } RectCCRectMake( y,monospace!important; Font-size:1em!important; min-height:inherit!important; color:black!important">height) { Rect(x,y,wIDth,height); } 总结 以上是内存溢出为你收集整理的cocos2d 自带算法全部内容,希望文章能够帮你解决cocos2d 自带算法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)