我想知道如何将相机放在远处(通过增加和减少eyeZ self.camera setEyeX:0 eyeY:0 eyeZ:1];
self.camera setEyeX:0 eyeY:0 eyeZ:180];
的值),包括动画(用于平滑),通常它会提供焦急的缩放。放置相机与动画
放置相机与动画
回答
如果从关闭中将“z”增加180,那么您肯定会得到一个生涩的动画,请尝试在动画上下文循环中运行此操作,在一段时间内增加值可以让您获得平滑'放大'。
你刚才提到'你',你是真的吗?因为我使用Z来移动相机近和远。 – rptwsthi 2011-05-23 11:49:32
对不起,我的确的意思是'Z' - 我已经相应地改变了答案。 – theiOSDude 2011-05-23 14:38:56
我的建议是创建自己的子类CCActionInterval
,说CCCameraZoomAnimation
并覆盖它的update
方法。除了能够精确地控制摄像机移动之外,采取行动的主要优点还包括通过CCEaseOut
/CCEaseIn
(等)使用此操作以获得更好的图形效果的可能性。
CCCameraZoomAnimation
将具有要修改其相机的节点作为目标,并将构造函数的另一个参数指定为最终的Z值。
@interface CCActionEase : CCActionInterval <NSCopying>
{
CCActionInterval * other;
}
/** creates the action */
+(id) actionWithDuration:(ccTime)t finalZ:(float)finalZ;
/** initializes the action */
-(id) initWithDuration:(ccTime)t finalZ:(float)finalZ;
@end
的update
方法被调用的参数dt
这表示经过时间,因为动作的开始并允许您轻松地计算出当前Z位置:
-(void) update: (ccTime) t
{
// Get the camera's current values.
float centerX, centerY, centerZ;
float eyeX, eyeY, eyeZ;
[_target.camera centerX:¢erX centerY:¢erY centerZ:¢erZ];
[_target.camera eyeX:&eyeX eyeY:&eyeY eyeZ:&eyeZ];
eyeZ = _intialZ + _delta * t //-- just a try at modifying the camera
// Set values.
[_target.camera setCenterX:newX centerY:newY centerZ:0];
[_target.camera setEyeX:newX eyeY:newY eyeZ:eyeZ];
}
您还需要实施copyWithZone
:
-(id) copyWithZone: (NSZone*) zone
{
CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration: [self duration] finalZ:_finalZ];
return copy;
}
,并利用startWithTarget
到
-(void) startWithTarget:(CCNode *)aTarget
{
[super startWithTarget:aTarget];
_initialZ = _target.camera....; //-- get the current value for eyeZ
_delta = ccpSub(_finalZ, _initialZ);
}
没有更多,没有更多。
对不起,如果复制/粘贴/修改产生了一些错误,但我希望总体思路清晰。
- 1. Xna相机放置
- 2. 画布与缩放动画
- 3. Unity相机动画无效?
- 4. 随机动画在Flash中的放置位置
- 5. 动画缩放与RaphaelJS
- 6. 动画图像幻灯片与移动相机
- 7. Java3d:移动相机和动画
- 8. 我想将imageview放置在与动画不同的位置
- 9. iOS 4隐藏的CATransition动画(相机虹膜动画)
- 10. 没有动画的地图相机位置急剧变化
- 11. A-Frame 0.6.1 - 相机旋转动画
- 12. 相机翻转动画使用TextureView
- 13. 的iOS - MapKit相机旋转动画
- 14. 动画规模:按钮相继与在机器人
- 15. 与速度0相比,jQuery的动画开销与直接设置css相比
- 16. 在相机预览版上放置ImageView
- 17. Push/Pop UIViewController动画效果与相机滤镜和完整相机视图相同
- 18. 何处放置动画代码?
- 19. MKAnnotations自定义引脚放置动画
- 20. 在CAShapeLayer中展开放置动画
- 21. 捏缩放相机
- 22. 相当于内置UIView动画的核心动画
- 23. Android动画Flash与HTML5相比,Android的原生动画库?
- 24. 画布动画放慢
- 25. 画布动画放慢
- 26. 相对位置和jQuery动画
- 27. jquery动画位置 - 绝对vs相对
- 28. 开关顶杆与动画(机器人)
- 29. 问题与uiscrollview setcontentoffset动画不滚动时动画:是设置
- 30. 从相机和画廊
我想下面的链接将帮助你解决问题。 [基本动画](http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/AnimatingLayers.html)。看看那个页面中的**显式动画**。 – Ilanchezhian 2011-07-08 06:09:01