ios - Physics Body edges IOS8, Sprite Kit -
So after the iOS game tutorial, its Io7 does not have many for 8
Is considered a bouncing ball around, but only bounces above and below the screen, if it comes to the edge, the ball is screened
#import "GameScene.h" @ Implementation GameScene - (zero) didMoveToView: (SKView *) See {/ * setup your view here / self.backgroundColor = [SKColor whiteColor]; Self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect: self.frame]; Self.physicsWorld.gravity = CGVectorMake (0, 0); SKSpriteNode * ball = [SKSpriteNode spriteNodeWithImageNamed: @ "ball"]; Ball.position = CP pointmaking (CGRactgetMIDX (SelfFreem), CGRactGate MDY (SelfFreem)); Ball.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius: ball.frame.size.width / 2]; //ball.physicsBody.friction = 0; Ball.physicsBody.linearDamping = 0; Ball.physicsBody.restitution = 1; [Self linking child: ball]; CGVector myVector = CGVectorMake (0, 5); [Applying Ball.physicsBody Impulse: myVector]; } - (Zero) Update: (CFETMInterval) Present time {/ * is presented to each frame * /} @end
Something should be simple here, but I do not think so Find an answer on stack overflow
Use NSLog to check the size of your view: NSLog (@ "% F,% f", self.size.width, self.size.height);
There is a problem with the spritekit, due to which the visual dimension causes you to cause closure. If this is happening in your case, be sure to change the size of your view correctly:
- (zero) DEMOVATTV: (SQL *) view {/ * Setup Your View Here is / self.size = self.view.frame.size; Self.backgroundColor = [SKColor whiteColor]; Self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect: self.frame]; Self.physicsWorld.gravity = CGVectorMake (0, 0); SKSpriteNode * ball = [SKSpriteNode spriteNodeWithImageNamed: @ "ball"]; Ball.position = CP pointmaking (CGRactgetMIDX (SelfFreem), CGRactGate MDY (SelfFreem)); Ball.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius: ball.frame.size.width / 2]; //ball.physicsBody.friction = 0; Ball.physicsBody.linearDamping = 0; Ball.physicsBody.restitution = 1; [Self linking child: ball]; CGVector myVector = CGVectorMake (50, 20); [Applying Ball.physicsBody Impulse: myVector]; } - (zero) Update: (CFTimeInterval) currentTime {/ * is called before each frame * /}
Comments
Post a Comment