sprite-kit

iOS SpriteKit How to make stroke color transparent?

空扰寡人 提交于 2020-01-03 03:21:11
问题 I do some simple games using SpriteKit now. There is one problem with stroke color in drawing process. I have to do my colored shapeNode transparent, but my stroke color stays the same every time. I've tried different techniques to do my node be entirely transparent: 1)setting alpha component to stroke color 2)setting alpha component to whole node. It didn't help. Is there is any way to achieve or get around this? Creation of my node CGMutablePathRef arc = CGPathCreateMutable(); cardWidth =

Spritekit: Efficiently create many SpriteNodes

不打扰是莪最后的温柔 提交于 2020-01-03 03:14:29
问题 I am using SpriteKit to write a bullet-hell style shoot-em-up, and the SK framework seems to be able to handle hundreds of nodes at 60fps without any problems at all. My problem however is that sometimes I need to spawn 50+ nodes in a single frame, and that does seem to cause the odd hitch in framerate. Are there any tricks I should be using to make sure that creation of many nodes is as performant as possible? I am re-using SKTextures, should I also have a persistent collection of

SpriteKit - Mouse Snaps to Center On Sprite Drag

女生的网名这么多〃 提交于 2020-01-03 01:42:08
问题 I'm trying to create an iOS game and I have it so that when the item is touched and moved it is dragged. When it is dragged the mouse is snapped to the center of the sprite. How could I make it so that this wouldn't happen? Here is an example of what is happening. Here are the functions dealing with touch input override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { var papers = 0 for touch in (touches as! Set<UITouch>) { let location = touch.locationInNode(self) let

spritekit didBeginContact three object not worked

社会主义新天地 提交于 2020-01-03 00:35:39
问题 I am tring to [didBeginContact] by three nodes. I wrote under code. But not work correctly. when white rectangle fole without hitting black or white rectangle, println("black"), and println("blue") work... whien white rectangle hit black rectangle, println("blue") work... import SpriteKit class GameScene: SKScene, SKPhysicsContactDelegate { let blackCategory: UInt32 = 0x1 << 0 let whiteCategory: UInt32 = 0x1 << 1 let blueCategory: UInt32 = 0x1 << 2 override func didMoveToView(view: SKView) {

How to show iAd on a certain SKScene and hide it on the other one

爷,独闯天下 提交于 2020-01-02 18:37:11
问题 I'm making a simple game and I would like to add an iAd at the top of the Game Over Screen. I could add it on to the UIViewController , but then it would show up while playing, which is something I don't want. Is there a way to make the iAd appear only on a certain SKScene ? Thanks for all your help! 回答1: The most clean solution is to declare and implement a protocol to let the UIViewController know that it should hide the ad. @protocol MySceneDelegate <NSObject> - (void)hideAd; - (void

iOS Sprite Kit: How to make Sprite follow Touches

两盒软妹~` 提交于 2020-01-02 17:48:32
问题 I'm new to Sprite Kit and I'm wondering how you can make a sprite follow the touches. For example, my player sprite is on the bottom of the screen. When I tap on the top of the screen, the player sprite should move to the touch point with a certain speed - and if I move my finger it should always be pointing towards the touch point. This is how I tried to implement it: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { for (UITouch *touch in touches) { CGPoint location = [touch

iOS Sprite Kit: How to make Sprite follow Touches

给你一囗甜甜゛ 提交于 2020-01-02 17:47:49
问题 I'm new to Sprite Kit and I'm wondering how you can make a sprite follow the touches. For example, my player sprite is on the bottom of the screen. When I tap on the top of the screen, the player sprite should move to the touch point with a certain speed - and if I move my finger it should always be pointing towards the touch point. This is how I tried to implement it: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { for (UITouch *touch in touches) { CGPoint location = [touch

How check the .spriteatlas sizes generated by Xcode?

限于喜欢 提交于 2020-01-02 16:52:10
问题 I'm using texture atlas for handling my images. I didn't created the atlas by myself however I let Xcode to do this for me: My question is: How can I see this file or know its properties (I mean, sizes and weight)? What if and how can I know if the sizes exceed the maximum size of 4098 x 4098 pixel? 来源: https://stackoverflow.com/questions/33561727/how-check-the-spriteatlas-sizes-generated-by-xcode

Joints break when zooming

こ雲淡風輕ζ 提交于 2020-01-02 16:20:44
问题 I've been rehearsing Sprite Kit lately and I've come across a very strange problem. When zooming (changing the scale of) the parent node, bodies that are joined together by SKPhysicsJointPin separate from each other gradually and then joints break. Let me show you the images. This is for the normal state: Here's when zoomed in: And here's when zoomed out: If you ask how I join bodies: I join the brown sticks to the blue nodes on the center of the blue nodes. Any ideas what my problem is? EDIT

SpriteKit: Passing variable from GameViewController to GameScene

时间秒杀一切 提交于 2020-01-02 16:18:53
问题 I created a menu in Storyboard that passes some information through a segue to GameViewController. Ideally, I could use that segue to pass the information directly to GameScene.swift where I need it, but I'm not sure that's an option since a scene is just a view and not a view controller. So, I pass the information to the GameViewController and that works great. But now, how to I get it to GameScene.swift? Segue from menu to GameViewController func passToGame(game: String) { performSegue