小编Seb*_*ian的帖子

变色精灵Cocos2d

我需要我的精灵过渡到一种颜色到另一种颜色然后......就像蓝色色调然后是绿色然后是紫色,但我找不到任何好的动作,我想知道,我应该使用动画吗?或者是否有针对此的合并行动?

animation colors cocos2d-iphone

4
推荐指数
1
解决办法
9844
查看次数

Cocos2D无限背景图片

我很好奇如何在cocos2d中创建无限背景.例如,假设我正在构建一个从左到右运行的应用程序的应用程序,我希望他无限运行.那么在那种情况下,我必须拥有无尽的背景,这样男人才能继续奔跑.我一直在搜索这个问题,并没有找到任何实际可行的东西.

任何类型的建议,答案和提示都非常感谢.

谢谢

background objective-c cocos2d-iphone

4
推荐指数
1
解决办法
2726
查看次数

我的“exit(0)”函数将“:成功”打印到标准输出。我怎么能阻止这个?

我已经谷歌了。我无法弄清楚发生了什么。

这个:

perror("some error message");
exit(0);
Run Code Online (Sandbox Code Playgroud)

将其打印到标准输出:

“一些错误信息:成功”

c unix

4
推荐指数
1
解决办法
5964
查看次数

如何获得日期字符串的时间

如何根据我的时区从日期时间字符串中获取时间.我的时区时间是格林威治标准时间+5:30.日期时间看起来像 -

04/03/2013 3:30:00 AM
Run Code Online (Sandbox Code Playgroud)

我希望输出像 -

9:00:00 AM
Run Code Online (Sandbox Code Playgroud)

提前致谢.

datetime objective-c

3
推荐指数
2
解决办法
4613
查看次数

使用NSString设置标签的颜色

我想创建一个方法并使用字符串值"redColor"为标签设置UIColor.tableColorName是NSString"redColor",我尝试应用选择器来创建UIColor并将其应用于我的textLabel.谢谢

-(void) changeLabelColor
{
    SEL labelColor = NSSelectorFromString([NSString stringWithFormat:[@"%@", tableColorName]]);

    UIColor *color = [[UIColor class] performSelector:labelColor];
    self.textLabel.textColor = color;
}
Run Code Online (Sandbox Code Playgroud)

objective-c selector nsstring uicolor ios

3
推荐指数
1
解决办法
1082
查看次数

如何更改传递给函数的结构的值

嗨朋友,我正在练习结构.我有这两个函数返回结构,我将它复制到main中的本地结构.我的第二个函数通过输入不同的实体来更改这些本地struct成员 现在我在调用每个函数后打印结果,令我惊讶的是我注意到两个函数之后的打印结果是一样的.我无法理解这里发生了什么......你能解释一下我...谢谢!

 #include <stdio.h>
 #include <stdlib.h>

 struct student{
        char name[30];
        float marks;
        };


 struct student read_student();
 void read_student_p(struct student student3);
 void print_student(struct student student2);

 int main()
 {
     struct student student1;
     student1 = read_student();
     print_student(student1);
     read_student_p(student1);
     print_student(student1);
     system("pause");
     return 0;
 }

 //This is my first function
 struct student read_student()
 {
      struct student student2;
      printf("enter student name for first function: \n");
      scanf("%s",&student2.name);

      printf("enter student marks for first function:\n");
      scanf("%f",&student2.marks);

      return student2;
 }

//function to print 
void print_student(struct student my_student)
{
    printf("Student name …
Run Code Online (Sandbox Code Playgroud)

c

3
推荐指数
1
解决办法
2万
查看次数

如何将SEL传递给dispatch_async方法

我正在尝试创建一个泛型方法,它将一个SEL参数作为参数传递给dispatch_async执行,但我无法如何执行传入的SEL.请允许有人帮助我.

// Test.m

-(void) executeMe
{
    NSLog(@"Hello");
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    SEL executeSel = @selector(executeMe);
    [_pInst Common_Dispatch: executeSel];
}

// Common.m
-(void) Common_Dispatch:(SEL) aSelector
{
    dispatch_async(iDispatchWorkerQueue, ^(void) {
        // How to execute aSelector here?
    });
}
Run Code Online (Sandbox Code Playgroud)

objective-c selector grand-central-dispatch

3
推荐指数
1
解决办法
397
查看次数

iphone xCode使用未声明的标识符

我刚刚开始在objective-c编程,我遇到了"使用未声明的标识符'uneImage'的问题;你的意思是'_uneImage'?".很多帖子谈到这个,但我还没有找到解决方案.

.H :



    #import 


    @interface ViewController : UIViewController 
    {
        UIImagePickerController *picker;
    }

    @property (weak, nonatomic) IBOutlet UIImageView *uneImage;


    - (IBAction)album:(id)sender;
    @end

Run Code Online (Sandbox Code Playgroud)

.M



    #import "ViewController.h"

    @interface ViewController ()

    @end

    @implementation ViewController

    - (IBAction)album:(id)sender
    {
        picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        [self presentViewController:picker animated:YES completion:nil];
    }

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
        uneImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
        [picker dismissViewControllerAnimated:YES completion:nil];
    }

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a …
Run Code Online (Sandbox Code Playgroud)

objective-c

2
推荐指数
1
解决办法
6054
查看次数

文件目录订单文件?IOS

我以这种方式将许多不同的图像保存到文档目录:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                     NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

int num = arc4random() % 100000000000000;

NSString* path = [documentsDirectory stringByAppendingPathComponent: [NSString stringWithFormat:@"%dtest.png", num]];
NSData* data = UIImagePNGRepresentation(image);
[data writeToFile:path atomically:YES];
Run Code Online (Sandbox Code Playgroud)

然后我用这种方式读取文件:

NSString *stringPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,     NSUserDomainMask, YES)objectAtIndex:0];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,     NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
//NSString* FinalPath = [documentsDirectory stringByAppendingPathComponent: @"Images/"];

NSArray *filePathsArray = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:documentsDirectory  error:&error];

for(int i=0;i<[filePathsArray count];i++)
{
    NSString *strFilePath = [filePathsArray objectAtIndex:i];
    if ([[strFilePath pathExtension] isEqualToString:@"jpg"] || [[strFilePath pathExtension] …
Run Code Online (Sandbox Code Playgroud)

objective-c nsfilemanager ios

2
推荐指数
1
解决办法
347
查看次数

Javascript从路径获取img的宽度

我认为应该有一个简单的解决方案,但我无法弄清楚。我想要做的是通过其路径(未在屏幕上呈现)获取图像的宽度/高度。

喜欢:

var img = ImageInfo(path);
alert(img.width);
Run Code Online (Sandbox Code Playgroud)

(我想用普通的 javascript 来做这个)

javascript

2
推荐指数
1
解决办法
3069
查看次数