Sending a CGPoint to iPhone 6 using GameKit

I’m working on a multiplayer game using GameKitHelper.
For now I am just testing the communication. I am using my iPhone 5 and the simulator, and the default “game” that Xcode makes when you create a game project (the one with the spaceships).

Everything works fine, except for when I run the simulator as iPhone 6 or 6+

I get the following log:

On the phone that I tapped:

Adding Ship At: (315.0, 272.5)

On the receiving phone:

2015-05-29 11:16:45.559 GameCenter Swift[903:17986] Point message received

Adding Ship At: (inf, inf)

Here is the relevant code:

 - (void)match:(GKMatch *)match 
didReceiveData:(NSData *)data
    fromPlayer:(NSString *)playerID {
    Message *message = (Message*)[data bytes];
    if (message->messageType == kMessageTypePoint) {
        MessagePoint * messagePoint = (MessagePoint*)[data bytes];
        NSLog(@"Point message received");
        [self.delegate receivedPoint:messagePoint->point];        

- (void)sendFactorX:(CGFloat) x 
            FactorY:(CGFloat) y{
    MessagePoint message;
    message.message.messageType = kMessageTypePoint;
    message.point = CGPointMake(x, y);
    NSData *data = [NSData dataWithBytes:&message length:sizeof(MessagePoint)];
    [self sendData:data];

typedef struct {
    Message message;
    CGPoint point;
} MessagePoint;

typedef struct {
    MessageType messageType;
} Message;

typedef enum {
} MessageType;

Source: ios

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.