这是我提供UIImagePickerController的代码:
// Show the media browser with our settings, then the browser will call our delegate if needed
- (BOOL) startMediaBrowserFromViewController: (UIViewController*) controller
usingDelegate: (id <UIImagePickerControllerDelegate,
UINavigationControllerDelegate>) delegate {
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO)
|| (delegate == nil)
|| (controller == nil))
return NO;
UIImagePickerController *mediaUI = [[[UIImagePickerController alloc] init] autorelease];
mediaUI.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
// Check for images type
NSArray * availableTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum];
BOOL imgsOnlyAvailable = NO;
// Check if we have only images
for (int i …Run Code Online (Sandbox Code Playgroud) 我已经尝试了许多不同的技术,在我的游戏中应用逼真的重力特征但到目前为止没有运气.我计划为那些可以向我展示或(分享)一些将重力应用于Cocos2D中的CCSprite的代码的人提供100点奖励.
到目前为止,我所做的只是丑陋或不切实际,我已经在很多不同的地方询问最好的方法是什么,但我还没有找到任何好看的重力技术.
无论如何,任何人都可以提供一些技巧/想法或他们的方法,只在不使用物理引擎的情况下将重力应用于Cocos2D中的CCSprite ?
谢谢!
在我的应用程序中,我在控制台中收到以下错误:
May 1 22:06:59 iPhone-4S app[93660] <Error>: CGContextAddPath: invalid context 0x0
May 1 22:06:59 iPhone-4S app[93660] <Error>: clip: invalid context 0x0
Run Code Online (Sandbox Code Playgroud)
可以发生这种情况的唯一区域是使用以下两种方法之一来调整大小或向UIImage添加圆角边缘.以下是方法:
- (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize {
// Create a graphics image context
UIGraphicsBeginImageContext(newSize);
// Tell the old image to draw in this new context, with the desired
// new size
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
// Get the new image from the context
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
// End the context
UIGraphicsEndImageContext();
// Return the new image.
return newImage;
}
- (UIImage*)roundCorneredImage: (UIImage*)orig …Run Code Online (Sandbox Code Playgroud) 所以在我的应用程序中,我试图在我的一种方法中进行简单的数学运算,而不使用大量的if/else语句.
所以我有一个名为'StartInt'的整数,最大值为13.现在我需要得到的是FinishInt一个整数,它将是这个模式的结果:
StartInt: 13 FinishInt: 1
StartInt: 12 FinishInt: 2
StartInt: 11 FinishInt: 3
Run Code Online (Sandbox Code Playgroud)
等等......直到StartInt为1且FinishInt为13.无论如何,我将如何实现这一目标?我知道这一定很简单,但我在数学方面并不是那么棒!:)
在Cocos2D 2.x中,我正在使用runAction在我的游戏中做一些动画.它工作得很好,但我希望动画重复一定次数.
所以我的伪代码就是这样:
CCSequence... action1, action2
[sprite runAction:theSequence];
Run Code Online (Sandbox Code Playgroud)
所以我只想重复一下这个动作(比方说3次),我该怎么做?我没有看到任何API来做这个,但也许我只是没有看到的东西.如果有人知道如何做到这一点,并可以分享这将是伟大的信息!
谢谢!