I made it a simple effect of hitting the ball on the screen, it only works with the top and bottom edges of idk, why, besides, when I try to use this code in the iOS 7 sprite set template in the initwithsize method, it works is this an error or something still? //
#import "GameScene.h"
@implementation GameScene
-(void)didMoveToView:(SKView *)view {
self.backgroundColor = [SKColor whiteColor];
SKSpriteNode *ball =[SKSpriteNode spriteNodeWithImageNamed:@"ball"];
ball.position =CGPointMake(self.frame.size.width/2, self.frame.size.height/2);
ball.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:ball.frame.size.width/2];
self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame];
self.physicsWorld.gravity = CGVectorMake(0, 0);
CGVector impulse = CGVectorMake(20,20);
[self addChild:ball];
[ball.physicsBody applyImpulse: impulse];
ball.physicsBody.restitution = 1;
ball.physicsBody.friction = 0;
ball.physicsBody.linearDamping = 0;
}
-(void)update:(CFTimeInterval)currentTime {
}
@end
source
share