Flip Everything on Screen After a Fixed Interval has Elapsed - Cocos2d
I have a timer set up, in place, and working fully. My problem is that I do not know if it is possible to completely flip everything on screen and keep it in the same position after a certain amount of time has elapsed.
E.G.
I开发者_StackOverflow社区 have a tree. After 30 seconds has passed flip the orientation from "landscapeleft" to "landscapeRight" and flip all sprites/timers on screen.
Is it possible?
Should I just change the orientation, check to see if the orientation has changed and if it has, change the sprites rotation?
Also, I would really like to Thank EVERYONE on this site for all of there help and putting up with my "easily answered" questions.
Thank You!
you could use a scheduling method like nash suggested along with a CCDirector orientation method [[CCDirector sharedDirector] setDeviceOrientation:kCCDeviceOrientationPortrait];
or whichever orientation you need.
-(void) flipOrientation:(ccTime)delta {
CCDirector *director = [CCDirector sharedDirector];
if ([director deviceOrientation] == kCCDeviceOrientationLandscapeLeft )
[director setDeviceOrientation:kCCDeviceOrientationLandscapeRight];
else
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
}
then when you schedule your method
[self schedule:@selector(flipOrientation:) interval:30.0];
this should do what you are asking for however i strongly suggest, as nash said, that you rotate instead of setting the orientation. You can rotate your main layer, or gameScene.. it will be more responsive and you can have control over how it animates. You can do it the same way as above by scheduling but instead of setting device Orientation just rotate your layer.... hope this helps
精彩评论