sprite-kit

Constant speed orbit around point with SKNode

空扰寡人 提交于 2019-12-17 19:50:52
问题 My objective is to have secondBody 'orbit' firstBody with a constant velocity (500 in this case). Based on Constant movement in SpriteKit I have implemented the following: override func didMoveToView(view: SKView) { physicsWorld.gravity = CGVector(dx: 0, dy: 0) let firstNode = SKShapeNode(circleOfRadius: 10) addChild(firstNode) firstNode.position = CGPointMake(CGRectGetWidth(frame) / 2.0, CGRectGetHeight(frame) / 2.0) let firstPhysicsBody = SKPhysicsBody(circleOfRadius: 10) firstPhysicsBody

Sprite Kit OS X: SKTexture size property is incorrect

前提是你 提交于 2019-12-17 19:46:38
问题 I'm testing a game on the OS X version of Sprite Kit, and find that some textures report their size incorrectly. I'm wondering if anyone else is seeing this problem and whether there is an explanation for it? Just to rule out any other issues before I report this as a bug. If this is a known bug, please say so. I'm loading this texture, it is 256x256 pixels in size: When I log the SKTexture created from this image, then the SKTexture description gives me the correct size but the size property

Swift: Is there an easy way to draw shapes and detect whether they intersect? [duplicate]

孤人 提交于 2019-12-17 19:44:27
问题 This question already has an answer here : Swift: detecting intersection from sprite kit SKShapeNode drawings (1 answer) Closed 5 years ago . Is there an easy way to draw shapes in Swift (preferrably with Sprite-Kit) and then detect if and where they intersect? Like here's an intersecting shape: 回答1: If this consists of a series of line segments, one can adapt Martin R's answer to UIBezierPath intersect to not only detect intersections, but to also identify where the intersections are: func

Drag Rotate a Node around a fixed point

不羁的心 提交于 2019-12-17 19:36:05
问题 I'm trying to create a spinable node similar to the "prize wheel" in this question. So far I have the flinging capability, adding angular impulses on a physics body using a UIPanGestureRecognizer that works really well. I can also stop the spinning using a touch. Now I'm trying to allow fine adjustment of the wheel using a drag or swipe gesture so if the player isn't happy with what they end up with they can manually spin/drag/rotate it to their favoured rotation. Currently I save the

swift spritekit Facebook share button

余生长醉 提交于 2019-12-17 19:31:24
问题 Hey there my app is almost ready for release but i want to add a Facebook share button. The thing is i have no idea how the communication between the scene and the viewcontroler works. i did my research but only found code in obj-c like this one - (void)lkFaceBookShare { NSString *serviceType = SLServiceTypeFacebook; if (![SLComposeViewController isAvailableForServiceType:serviceType]) { [self showUnavailableAlertForServiceType:serviceType]; } else { SLComposeViewController

Game Engine Collison Bitmask… Why 0x01 etc?

邮差的信 提交于 2019-12-17 19:22:45
问题 Coming across this situation both in Sprite Kit (iOS Development) and in Cocos2d-x (which I know was pretty much the inspiration for Sprite Kit, hence why they use a lot of the same tools), I finally decided to figure out why this happens: When using a physic engine, I create a sprite, and add a physicsBody to it. For the most part, I understand how to set the category, collision, and contact bitmasks, and how they work. The problem is the actual bitmask number: SpriteKit: static const uint32

Draw a hole in a rectangle with SpriteKit?

China☆狼群 提交于 2019-12-17 19:03:19
问题 How to draw a hole in a rectangle? I want to draw a rectangle which has a empty hole inside it and the background can be show. I am using SKShapeNode to create a rectangle, but I have no idea how to make a hole (circle) inside it. This is what I run your code, but my circle is not empty, the circle is black, I want it to be empty. Is there any mistake I didn't mention? 回答1: Here's the code. import SpriteKit class GameScene: SKScene { override func didMove(to view: SKView) { let effect =

Draw a hole in a rectangle with SpriteKit?

浪尽此生 提交于 2019-12-17 19:01:38
问题 How to draw a hole in a rectangle? I want to draw a rectangle which has a empty hole inside it and the background can be show. I am using SKShapeNode to create a rectangle, but I have no idea how to make a hole (circle) inside it. This is what I run your code, but my circle is not empty, the circle is black, I want it to be empty. Is there any mistake I didn't mention? 回答1: Here's the code. import SpriteKit class GameScene: SKScene { override func didMove(to view: SKView) { let effect =

Sprite kit sprites loading performance improvement

折月煮酒 提交于 2019-12-17 19:00:29
问题 I am making a sprite kit game and I am using the plist file to set properties of each level. One of the properties in my plist file is a dictionary called patterns, which contains n items, where each of the items is a block, with hand typed x and y positions. This model is working perfectly fine for the kind of game I am making, as it is very convenient to set the levels right in a quick manner. However, I am facing one drawback I cant solve myself due to the lack of coding experience: some

applyForce(0, 400) - SpriteKit inconsistency

一个人想着一个人 提交于 2019-12-17 18:19:07
问题 So I have an object that has a physicsBody and gravity affects it. It is also dynamic. Currently, when the users touches the screen, I run the code: applyForce(0, 400) The object moves up about 200 and then falls back down due to gravity. This only happens some of the time. Other times, it results in the object only moving 50ish units in the Y direction. I can't find a pattern... I put my project on dropbox so it can be opened if anyone is willing to look at it. https://www.dropbox.com/sh