GPP*_*GPP 2 objective-c cocos2d-iphone
谷歌什么都没产生,所以我想问问.ccp实现了什么?
以下是在方法中使用ccpClamp的示例.
-(void) moveCamera:(CGPoint)pos
{
CGPoint to = ccpClamp(pos, cameraMin, cameraMax);
to = ccpSub(to, cameraOffset);
[self.camera setCenterX:to.x centerY:to.y centerZ:0];
[self.camera setEyeX:to.x eyeY:to.y eyeZ:[CCCamera getZEye]];
// update hud-level sprites
[(HudLayer*)[self.parent getChildByTag:kTagHudLayer] moveSprites:[self getCameraPosition]];
}
Run Code Online (Sandbox Code Playgroud)
在官方文档并没有解释这个词是什么钳手段,但它是用来值限制为一组边界(低,高).在您的示例中,它相当于:
if (pos < cameraMin)
return cameraMin;
else if (pos > cameraMax)
return cameraMax;
else
return pos;
Run Code Online (Sandbox Code Playgroud)
据dictionary.com,clamp表示:
- 通常由一些刚性材料制成的装置,用于加强或支撑物体或将它们紧固在一起.
- 具有相对侧面或部件的器具,可以调节或靠近在一起以保持或压缩某物.
| 归档时间: |
|
| 查看次数: |
1243 次 |
| 最近记录: |