sprite-kit

How can I apply friction to a circular SKPhysicsBody

て烟熏妆下的殇ゞ 提交于 2019-12-25 02:34:25
问题 I am trying to understand friction, or some other aspect of physics, in SpriteKit. I created a circle that rotates. I placed a square on top of the rotating circle. I expected the square to rotate along with the circle and fall off, but the square does not move. I set physicsBody.friction = 1.0 in an attempt to make the surfaces sticky but it does not help. What changes to physics do I need to make so that the square is affected by the circle's rotation? I created a self-contained example

Warning: Attempt to present * on * whose view is not in the window hierarchy with SLComposeViewController

匆匆过客 提交于 2019-12-25 02:27:18
问题 When I push the twitter image in the game, I want to show share image(SLComposeViewController's modal display). But, when I push the twitter button, the display doesn't show and the log says like the title. Then, I searched similar issues but I am not sure what should I do... [ViewDidLoad] and [ViewDidAppear] is important thing, I know. Below is my code. ViewController.m #import "ViewController.h" #import "NewGameScene.h" #import <Social/Social.h> #import "GameOverScene.h" @interface

Sprite Kit - Defining the variables for multiple scenes

佐手、 提交于 2019-12-25 02:26:10
问题 I have two questions about having multiple level scenes. There are multiple scenes for different levels. All those scenes make use of the same Bit Mask Categories and other variables defined in their .h file. Is there a way to define the Bit Mask Categories and other variables in one single file, in stead of the .h file of every single level scene? In the update method of a level scene, I detect if the float 'score' is higher or equal to 100. If that is the case, change the scene to the next

SKShapeNode Circle not appearing circular

久未见 提交于 2019-12-25 02:04:42
问题 I am working on an app where there should be a red circle on the screen. At first when I tested with only one scene, the circle appeared circular just fine. However, I have added in another scene and now the circle appears like this: The circle appears to be much longer in the x direction. Here is the code I use to make the circle (All of this in an skscene): let ball = Ball(circleOfRadius: 500)//ball is a subclass of SKShapeNode ball.setScale((self.frame.height / 6) / 1000) ball.position =

Sprite Node position not updating with touch?

大城市里の小女人 提交于 2019-12-25 01:29:43
问题 Essentially, what I want is for when I touch a node, I want to be able to move it across the screen. The problem is that whenever I move my finger too fast, the node just stops following it. The spriteNodes in particular that I'm trying to do this with have physics bodies and animating textures so I tried to do the same code with a completely plain spriteNode and I've encountered the same problem. The code that I have here is pretty simple so I'm not sure if this is a problem with what I've

Preload a Scene to prevent lag?

强颜欢笑 提交于 2019-12-25 01:19:28
问题 Hello guys i have made the first Level of my game, but always when i go from the main menu screen to the first level the screen freezes for like 2 Seconds and the transition from the Main screen to the game is very delayed and laggy and it sometimes doesn't even show up. Is there a way to preload the Scene in the background to prevent the lag? 回答1: you can load the resources for the scene in a different thread. I do this in my game to get really snappy scene transitions despite the fact im

skphysicsbody collision between two same nodes

烈酒焚心 提交于 2019-12-24 23:07:08
问题 I created a class that declare a ball of kind 'SKShapeNode'. in its init I set the 'SKPhysicsBody' properties. before I set these properties (leave it as default) when one ball touch another one the both affected by the touch (like: move to different position depends on the collision position). after I set the 'physicsBody' properties it won't affected any more - one ball appear to be above the other one (like frame on frame - hiding it). how can I set this property? I look at apple doc and

Determine Node Touched in Gesture Recognizer

南笙酒味 提交于 2019-12-24 20:36:23
问题 I have a SpriteKit scene that can have thousands of distinct nodes in it. I am also implementing a single-tap gesture recognizer on the scene, in the hopes that I can determine which node has been touched in the scene once the gesture recognizer is triggered. Currently, my (non-working) code looks like this: @objc func singleTap(_ sender: UIPinchGestureRecognizer) { print("single tap gesture recognized") if sender.numberOfTouches == 1 { let touchPoint = sender.location(in: self.view) let

increase game speed and keep same distance between nodes

北城余情 提交于 2019-12-24 19:47:15
问题 I am working on a game where I have two functions . The first function is used to create a row of obstacles. The gameSpeed variable is used to decide how frequently a new row of obstacles is added. Example : if I set gameSpeed to 3 then a new obstacle row is added every 3 seconds. func addobstalce() { lastYieldTimeInterval += timeSinceLastUpdate if lastYieldTimeInterval > gameSpeed { lastYieldTimeInterval = 0 nextRow(cR: currentRow) } } and the second function is used to add movement to them.

Bendable arm rotation in SpriteKit - rotate at point

主宰稳场 提交于 2019-12-24 18:36:05
问题 I am trying to simulate a bendable arm using SpriteKit. I have an upper arm SKShapeNode and a lower arm SKShapeNode . How would I rotate the lower arm so it rotates at the elbow instead of rotating on itself? Here is my straight arm with the upper arm being tan colored and the lower arm being cyan colored. This is what it looks like after a -90 degree rotation on the lower arm How would I simulate the lower arm being connected to the upper arm at the elbow? I've tried multiple SKConstraint s