作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我怎样才能使 CCTransitionPageTurn
以镜像的方式 curl 页面到它当前的实现方式(就像你想要翻一本阿拉伯语书的页面一样)。这是 CCActionPageTurn3D
,我应该在哪里反转角度或使用 (1024 - x)
? :-)
-(void)update:(ccTime)time
{
float tt = MAX( 0, time - 0.25f );
float deltaAy = ( tt * tt * 500);
float ay = -100 - deltaAy;
float deltaTheta = - (float) M_PI_2 * sqrtf( time) ;
float theta = /*0.01f*/ + (float) M_PI_2 +deltaTheta;
float sinTheta = sinf(theta);
float cosTheta = cosf(theta);
for( int i = 0; i <=gridSize_.x; i++ )
{
for( int j = 0; j <= gridSize_.y; j++ )
{
// Get original vertex
ccVertex3F p = [self originalVertex:ccg(i,j)];
float R = sqrtf(p.x*p.x + (p.y - ay) * (p.y - ay));
float r = R * sinTheta;
float alpha = asinf( p.x / R );
float beta = alpha / sinTheta;
float cosBeta = cosf( beta );
// If beta > PI then we've wrapped around the cone
// Reduce the radius to stop these points interfering with others
if( beta <= M_PI)
p.x = ( r * sinf(beta));
else
{
// Force X = 0 to stop wrapped
// points
p.x = 0;
}
p.y = ( R + ay - ( r*(1 - cosBeta)*sinTheta));
// We scale z here to avoid the animation being
// too much bigger than the screen due to perspectve transform
p.z = (r * ( 1 - cosBeta ) * cosTheta) / 7; // "100" didn't work for
// Stop z coord from dropping beneath underlying page in a transition
// issue #751
if( p.z<0.5f )
p.z = 0.5f;
// Set new coords
[self setVertex:ccg(i,j) vertex:p];
}
}
}
最佳答案
使用 CCTransitionPageTurn 并将 backwards 属性设置为 YES。
例子
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
CGSize screenSize = [[CCDirector sharedDirector] winSize];
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:[touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
if (location.x < (screenSize.width * .25) && location.y < (screenSize.height * .25)) {
CCTransitionPageTurn *transition = [CCTransitionPageTurn transitionWithDuration:1.75 scene:[Page1 scene] backwards:YES];
[[CCDirector sharedDirector] replaceScene:transition];
}
if (location.x > (screenSize.width * .75) && location.y < (screenSize.height * .25)) {
CCTransitionPageTurn *transition = [CCTransitionPageTurn transitionWithDuration:1.75 scene:[Page3 scene] backwards:NO];
[[CCDirector sharedDirector] replaceScene:transition];
}
}
取自here
关于iphone - Cocos2D CCTransitionPage从左到右转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10428381/
我有一个问题,我有一堆长度,想从原点开始(假装我正对着y轴的正端),我做一个右并沿着x轴正向移动了length_i的距离。这时我再右拐,走length_i的距离并重复n次。我可以做到,但是我认为有一种
我是一名优秀的程序员,十分优秀!