sprite-kit

SpriteKit - Return to a persistent scene in the same state it was left in.

我的梦境 提交于 2019-12-08 06:31:45
问题 The concept of being able to return to a previous scene from where you left off is briefly mentioned here: https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/DesigningGameswithSpriteKit/DesigningGameswithSpriteKit.html Other than that I can't find any more documentation on the subject. I know in other frameworks like Cocos2D you can pop scenes on a stack, and even have multiple scenes running at the same time. How do I get this to work in SpriteKit

How can you detect if SKShapeNode is touched?

旧城冷巷雨未停 提交于 2019-12-08 06:13:07
问题 I created a sknodeshape. How can I detect if the shape I made was touched(clicked)? Here is the code: (I solved it already) //metung_babi is the name of the SKShapeNode UITouch *touch = [touches anyObject]; CGPoint nokarin = [touch locationInNode:self]; SKNode *node = [self nodeAtPoint:nokarin]; if ([node.name isEqualToString:@"metung_babi"]) { NSlog(@"touch me not"); } my mistake was when I created the shape I put the SKShapeNode name before initializing it. 回答1: Implement the touch delegate

Use TableViewController inside SKScene

老子叫甜甜 提交于 2019-12-08 06:03:48
问题 I want a TableViewController to appear inside the scene whenever I click on a specific node as a small window. I created a TableViewController class to configure it. Here is my code inside SkScene: let table = Table() let smallerRect = CGRectMake(100, 100, 200, 100) let navRect = CGRectMake(0, 100, 200, 200) let nav = UINavigationController(rootViewController: table) nav.view.frame = navRect let frameView = UIView(frame: smallerRect) frameView.backgroundColor = UIColor.redColor() table.view

Using an .sks file to layout a complex object vs a SKScene file

一曲冷凌霜 提交于 2019-12-08 05:44:02
问题 Is it possible to use the SceneEditor to layout & create a complex Subclass of SKSpriteNode, load that information and create a custom object in your scene based on the sks file? My scenario is that I have a popup dialogs (which are nothing more than subclasses of SKSpriteNodes) with a lot of children on the dialog. I was hoping to lay it out in the Scene editor similar to how I lay out an SKScene, and then present it in my scene when needed. I realize that I could just create this object in

How to fix the share button on SpriteKit Swift when Players plays the game again Share Button shows up on the game scene?

梦想的初衷 提交于 2019-12-08 05:15:34
问题 Here is my code for my "Share" button: ShareButton = UIButton(frame: CGRect(x: 0, y:0, width: view.frame.size.width / 3, height: 60)) ShareButton.center = CGPointMake(CGRectGetMidX(self.frame), 3*CGRectGetHeight(self.frame)/4) ShareButton.setTitle("Share", forState: UIControlState.Normal) ShareButton.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal) ShareButton.addTarget(self, action: ("pressed:"), forControlEvents: .TouchUpInside) self.view?.addSubview(ShareButton) PS: My

sound is not playing when node is touched in spritekit swift

谁说我不能喝 提交于 2019-12-08 04:44:32
问题 I want to have a sound when a node is clicked. currently the code is: let sndButtonClick = SKAction.playSoundFileNamed("button_click.wav", waitForCompletion: false) and from touches began its override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { for touches: AnyObject in touches { let location = touches.locationInNode(self) if playButton.containsPoint(location) { playButton.runAction(sndButtonClick) playButton.removeFromParent() let nextScene = GamePlayMode(size: self

Custom Particle System for iOS

♀尐吖头ヾ 提交于 2019-12-08 04:42:45
问题 I want to create a particle system on iOS using sprite kit where I define the colour of each individual particle. As far as I can tell this isn't possible with the existing SKEmitterNode . It seems that best I can do is specify general behaviour. Is there any way I can specify the starting colour and position of each particle? 回答1: This can give you a basic idea what I was meant in my comments. But keep in mind that it is untested and I am not sure how it will behave if frame rate drops occur

How can I add UIView in **spriteKit**?

ⅰ亾dé卋堺 提交于 2019-12-08 04:34:31
问题 I am developing a game project using SpriteKit framework, now my requirement is i want to add UIView control in my spriteKit project but unable to do it. UIView *myview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 280, 480)]; [myview setBackgroundColor:[UIColor redColor]]; [self.scene.view addSubview:myview]; Currently i am adding UIView to SKScene like this but it is not working . thanks 回答1: [UIView transitionFromView:self.view toView:myview duration:0.25 options

SpriteKit - minimize quadcount

折月煮酒 提交于 2019-12-08 04:34:08
问题 I've been trying to teach myself SpriteKit and jumped into Raywenderlich's tutorials which said that QuadCount should be minimized for a better performance. I turned on showQuadCount, showDrawCount, showNodeCount for debugging. However, I saw quadcount is always equals to node count. Anyone can help me explain in a simple way what quadcount really is and give me an example on that quadcount is different from nodecount. (I did search google but I can not understand, so please do not give me a

SpriteKit: Sprites are moving through each other with a physicsBody already set

Deadly 提交于 2019-12-08 04:28:12
问题 So I have created a player who moves tile based and a wall surrounding the map to keep the player on the playground. Both have a physicsBody in them. My guess is, that my movement of the player is not properly and so the player bugs into the walls. Let me just show you my code: So this is the physicsBody of the Player: self.physicsBody!.usesPreciseCollisionDetection = true self.physicsBody!.categoryBitMask = PhysicsCategory.Player self.physicsBody!.contactTestBitMask = PhysicsCategory.House