sprite-kit

Create SKView programmatically?

谁都会走 提交于 2021-02-19 08:05:06
问题 I like my code to be explicit so I want to remove the storyboard file and create SKView programmatically. What I have tried so far: I created a SpriteKit game project in xcode . Deleted the storyboard file. Deleted sroryboard property from Info.plist Added this code found in an example to the AppDelegate : - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

SKPhysicsContact is there any way to determine which body is A and B?

我只是一个虾纸丫 提交于 2021-02-19 03:09:56
问题 in SpriteKit we detect the in the didBeginContact method. but this looks a bit stupid to do something like that: func didBeginContact(contact: SKPhysicsContact) { if let contactA = contact.bodyA.node?.name { if let contactB = contact.bodyB.node?.name { //now that we have safely unwrapped these nodes, we can operate on them if contactA == "ball" { collisionBetweenBall(contact.bodyA.node!, object: contact.bodyB.node!) } else if contactB == "ball" { collisionBetweenBall(contact.bodyB.node!,

SKPhysicsContact is there any way to determine which body is A and B?

故事扮演 提交于 2021-02-19 03:08:48
问题 in SpriteKit we detect the in the didBeginContact method. but this looks a bit stupid to do something like that: func didBeginContact(contact: SKPhysicsContact) { if let contactA = contact.bodyA.node?.name { if let contactB = contact.bodyB.node?.name { //now that we have safely unwrapped these nodes, we can operate on them if contactA == "ball" { collisionBetweenBall(contact.bodyA.node!, object: contact.bodyB.node!) } else if contactB == "ball" { collisionBetweenBall(contact.bodyB.node!,

SKPhysicsContact is there any way to determine which body is A and B?

[亡魂溺海] 提交于 2021-02-19 03:06:41
问题 in SpriteKit we detect the in the didBeginContact method. but this looks a bit stupid to do something like that: func didBeginContact(contact: SKPhysicsContact) { if let contactA = contact.bodyA.node?.name { if let contactB = contact.bodyB.node?.name { //now that we have safely unwrapped these nodes, we can operate on them if contactA == "ball" { collisionBetweenBall(contact.bodyA.node!, object: contact.bodyB.node!) } else if contactB == "ball" { collisionBetweenBall(contact.bodyB.node!,

SKPhysicsContact is there any way to determine which body is A and B?

时光毁灭记忆、已成空白 提交于 2021-02-19 03:06:36
问题 in SpriteKit we detect the in the didBeginContact method. but this looks a bit stupid to do something like that: func didBeginContact(contact: SKPhysicsContact) { if let contactA = contact.bodyA.node?.name { if let contactB = contact.bodyB.node?.name { //now that we have safely unwrapped these nodes, we can operate on them if contactA == "ball" { collisionBetweenBall(contact.bodyA.node!, object: contact.bodyB.node!) } else if contactB == "ball" { collisionBetweenBall(contact.bodyB.node!,

Create a raycast in spritekit

一个人想着一个人 提交于 2021-02-18 19:29:30
问题 I am building a game using Spritekit and am trying to build a raycast that will connect the player with the point where the player tapped. It will be like a rope that connects the player to the point where he or she tapped. For example if a player taps at the point x: 0, y: 0 then it will become a rope that connects both things with each other. With the time the rope will become shorter and the player will be dragged against it. The player does have a physicsbody. When the player releases the

Issues with SKPhysicsBody from Texture

你。 提交于 2021-02-11 13:46:32
问题 I have searched around the internet / StackOverflow for the past few days without much success in finding an answer to a few questions that I believe are intertwined in some way. How do I prevent my game from freezing when it is rendering an SKPhysicsBody from a texture? Why are my physics bodies sometimes not created at all, and why are they sometimes the wrong shapes? Below is the code I am using to try and generate these pillars (image attached at the bottom of the post. There are roughly

SpriteKit SKLabelNode attached to ARAnchor doesn't appear or appears fullscreen

会有一股神秘感。 提交于 2021-02-11 12:47:20
问题 I'm adding an anchor to my sceneView in the world origin position: let configuration = ARWorldTrackingConfiguration() sceneView.session.run(configuration) sceneView.session.add(anchor: ARAnchor(name: "world origin", transform: matrix_identity_float4x4)) sceneView.presentScene(SKScene()) I then choose to show a SKLabelNode at my anchor position func view(_ view: ARSKView, nodeFor anchor: ARAnchor) -> SKNode? { // Create and configure a node for the anchor added to the view's session. let

Why doesn't the call to the random function work in the sequence?

♀尐吖头ヾ 提交于 2021-02-10 06:09:59
问题 I am attempting to generate a random X position for a simple object, in order to have it bounce back and forth inside the scene in a Swift SpriteKit game. The repeatForever action should generate a random value and then move the object (a circle) multiple times to different locations, left and right. However, it acts only one time. It is as if the random function, which works correctly, is called only one time, and the action then simply continues to move the object to the same position

Why doesn't the call to the random function work in the sequence?

三世轮回 提交于 2021-02-10 06:06:18
问题 I am attempting to generate a random X position for a simple object, in order to have it bounce back and forth inside the scene in a Swift SpriteKit game. The repeatForever action should generate a random value and then move the object (a circle) multiple times to different locations, left and right. However, it acts only one time. It is as if the random function, which works correctly, is called only one time, and the action then simply continues to move the object to the same position