2011년 8월 20일 토요일

[IPhone Dev] 2 Button Alertview example.


Try the following~

UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Title"message:message delegate:self cancelButtonTitle:@"Cancel"otherButtonTitles:@"OK"nil];
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

    if (buttonIndex == 0)   //NO
    {
        
    }
    else    //OK
    {
        
    }
}



That's all~

2011년 8월 17일 수요일

[Game Center] How to post a score to the Game Center? Here is is!


For using game center, your app should be on the Itunesconnect and enable Game Cener.

If you did that, here is what you have to do now.

It is very simple. Try the following codes.



GKScore* score = [[[GKScore allocinitWithCategory:@"game category name"]autorelease];
            score.value = totalTime*100;
            
            [score reportScoreWithCompletionHandler:^(NSError* error)
             {
                 if(error != NULL)
                 {
                 }
             }];



It it very easy to post your score but... not much players want to even create account on GameCenter;;

I myself in My App am using both GameCenter and Cocoslive leader boards.

Result?

2000 people in cocoslive leader board.

and 

2 people in GameCenter leader board including me.


Have a good day~ :p

[Cocoslive] How to get a score from Cocoslive? Here it is!


I was gonna post it tomorrow but i decided to post it right now. why?

cause i dont have anything to do right now :p

Get to the point!


#import "CLScoreServerPost.h"

-(void) requestGlobalScore
{

    CLScoreServerRequest *request = [[CLScoreServerRequest alloc]initWithGameName:@"Mayday Timeattack" delegate:self];
  
    
    [request requestScores:kQueryAllTime limit:10 offset:currentScoreflags:kQueryFlagIgnore];

    [request release];
}
 
-(void) scoreRequestOk: (id) sender
{
    NSArray *scores = [sender parseScores]; 
    NSMutableArray * serverScore = [NSMutableArray arrayWithArray:scores];
}
 
 

Try the above lines then you will be find. 

If you have any questions, reply~

[Cocoslive] How to Post score to the cocoslive server

Try the following then you will find no problem with it!

Have fun~ :p

#import "CLScoreServerPost.h"

 

-(void) postScore:(NSString*)userName{
    CLScoreServerPost *server = [[CLScoreServerPost alloc]initWithGameName:@"Mayday Timeattack" gameKey:@"game key from cocoslive"delegate:self];
    
NSMutableDictionary *dict = [NSMutableDictionarydictionaryWithCapacity:3];
[dict setObject: [NSNumber numberWithInt:(int)(totalTime*100)]forKey:@"cc_score"];
[dict setObject:userName forKey:@"cc_playername"];
    
[server updateScore:dict];
}

-(void) scorePostOk: (id) sender
{

}

-(void) scorePostFail: (id) sender
{

}

2011년 8월 16일 화요일

[IPhone Dev] How to create a .plist file for Frame Sheet Animation

http://zwoptexapp.com/flashversion

go to the above site and try below~


1. File - Import Images 
2. Arragne - By Name & Height
3. File - Export Coordinates


Pretty easy huh?



Mayday Timeattack - Free on Appstore


[IPhone Dev] NSMutableArray Bad Access -while NSMutableArray reading

nonatomic


That's the one we have to know.


Im not describe what it is because that is not you wanna know :p


So i just get to the point.


if you get bad access error when you read a NSMutableArray, you may wanna use the array in @property way.


make it as a property then use like this


self.dotArray




@property (nonatomicretainNSMutableArray *dotArray;
  



Mayday Timeattack - Free on Appstore


[IPhone Dev] CGPoint in NSMutableArray

Cannot use NSMutableArray with CGPoint.


In .net we use like this


List<CGPoint> list;


but since we don't have that in objective-c, we use this.


NSMutableArray * pointArray = [NSMutableArray array];
        
[pointArray addObject:[NSValue valueWithCGPoint:location]];
[pointArray addObject:[NSValue valueWithCGPoint:lastPoint]];
        
CGPoint retrievedPoint = [[pointArray objectAtIndex:0CGPointValue];
 
no more words to say.


That's all~



Mayday Timeattack - Free on Appstore


[IPhone Dev] How to CGPoint compare? Here it is!

CGPoint a, b;
if(a == b)



The above codes does not work;; Ah~~~ no~~~


so you have to use below.



if (CGPointEqualToPoint(location, lastPoint)) {


    }

 



Mayday Timeattack - Free on Appstore


[IPhone Dev] Get point from touch

 Getting location for touch!
 
Get the position!

-(void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView:touch.view]; 
}



Mayday Timeattack - Free on Appstore

[IPhone Dev] Objective C - Singleton

That's the one im using!

+ (GameManager *)sharedGameManager
{
    static GameManager *singletonClass = nil;
    
    if(singletonClass == nil)
    {
        @synchronized(self)
        {
            if(singletonClass == nil)
            {
                singletonClass = [[self alloc] init];
            }
        }
    }
    
    return singletonClass;
}

Mayday Timeattack - Free on Appstore



[IPhone Dev]"This game is not recognized by Game Center" Problem

Straight to the point.

When get "This game is not recognized by Game Center" alert view when you are trying to add Game Center in you app on the device

but works on the simulator, well you are in no problem.

Just remove your app from the device and run on the device again.

It will work. Just got the problem and solved this problem after looked at this thread.

Thanks to Paul.


Mayday Timeattack - Free on Appstore


and now small talk :p

i used cocos2d and cocoslive for 
my game.

But i decided to go for Game Center. 

I haven't tried the "Campaign" from the admob site but i will try it layer.

Anyway looks like somehow they promote itself by "friends thing".

So.. i will update it with Game Center and see how it goes :p

Good day guys~