sprite-kit

scaleMode .fill not filling the scene view on iPad

£可爱£侵袭症+ 提交于 2019-12-11 07:15:48
问题 I created my game using the Universal images of dimensions 1136x640 (@2x) and 2208x1242 (@3x) for my start background. I changed the scaleMode property to .fill for iPad but it just fills the center with black borders all around. I thought .fill was suppose to extend the width and height to fill the scene view. I found a sample universal project that I tested and the images scaled with .fill for the iPad. They used, 568x320 (@1x), 1136x640 (@2x) and 1704x960 (@3x) for their images. I copied

iOS8 Beta 3 SpriteKit exc_bad_acces when running on device

老子叫甜甜 提交于 2019-12-11 07:09:44
问题 I am currently developing an app in Spritekit with Swift . The app worked perfectly on device and in the simulator until I updated to Xcode 6 Beata 3 and iOS 8 Beta 3. When I run the app in the simulator everything still works perfect. But running the app on the device causes a exc_bad_acces when I create a SKTextureAtlas . Is anyone facing a similar problem or can anyone help me how to solve this. I've alredy tried to run it on a device with iOS8 Beta 2 but I run into the same error here. I

How to set physics body for a sprite with rounded corners

可紊 提交于 2019-12-11 06:57:55
问题 I have created a SKShapeNode in the following way, let sprite = SKShapeNode(rect: CGRect(x: -20, y: -10, width: 40, height: 20), cornerRadius: 10) I also set a physics body like so, sprite.physicsBody = SKPhysicsBody(rectangleOf: sprite.frame.size) but I realized that the collisions and contacts weren't precise, so I changed showsPhysics to true and got the following. How can I make the physics body precise, even for the rounded corners? 回答1: From the documentation: Maybe the #4 is your case

Spritekit: passing from UIButtons to buttons as SKSpriteNode

六月ゝ 毕业季﹏ 提交于 2019-12-11 06:55:18
问题 I’m working on a SpriteKit game and at first I put 4 UIButton in my GameplayScene, but then I decided to create individual buttons as SKSpriteNode, programmatically made, and use a class (class Button: SKSpriteNode). I want my buttons fade and scale a little when pressed and then turn back to the original state. Buttons fade and scale down, but they stay in that state, don’t go back to normal state. What’s wrong with my code? import SpriteKit protocol ButtonDelegate: NSObjectProtocol { func

Why my physics bodies pass through each other after a few collisions in spritekit?

Deadly 提交于 2019-12-11 06:49:13
问题 I am working on a game which involves a character jumping on plateforms like the Doodle jump game. The problem is the character will pass through the plateform after a few collisions with it. For jumping i use restitution player.physicsbody.restitution = 1.0 I apply force to the physicbody of character based on accelerometer data in update: method. 回答1: You can try to use; sprite.physicsBody.usesPreciseCollisionDetection = YES; It is explained such as: A small body might move so fast that it

SKAction scaleXTo:-1

旧巷老猫 提交于 2019-12-11 06:46:56
问题 I am trying to mirror my SKSpriteNode using SKAction *mirrorDirection = [SKAction scaleXTo:-1 y:1 duration:0.0]; but every time I do, the sprite's physics body seems to get messed up and it drops off the screen. I have several objects (floors) beneath the sprite and it falls through all of them as if they are not there. This only happens when I mirror the sprite. Anyone know how to fix this? Update: Reseting the physics body as one answer suggested unfortunately did not fix the problem. It

updating an SKLabel to show the right integer

独自空忆成欢 提交于 2019-12-11 06:39:39
问题 ok so first off I have an achievement Variable that is defined from a struct like so: struct Achieve { var node: SKSpriteNode? var aName:String = "" var aDes:String = "" var aImage: String = "" { didSet { node?.texture = SKTexture(imageNamed: aImage) } } var aAmount:Int = 0 var aRequired:Int = 0 var aStage:Int = 0 } var Ach1 = Achieve(node: nil, aName: "Player", aDes: "Games Played", aImage: "locked", aAmount: 0, aRequired: 10, aStage: 1) My problem is when I try and change the number of the

Applying a CIFilter with SKEffectNode to a SKSpriteNode

大憨熊 提交于 2019-12-11 06:25:07
问题 I am trying to apply a CIFilter with SKEffectNode to a SKSpriteNode. Can't get this to work and not sure why. I got this working using a blur but cannot get the mono photo effect. Anyone have any insight? Thanks again. //Mono Effect (not working) let filter = CIFilter(name: "CIPhotoEffectMono") filter?.setDefaults() effectsNode.filter = filter self.addChild(effectsNode) effectsNode.addChild(SKSpriteNode) //Blur Effect (working) let filter = CIFilter(name: "CIGaussianBlur") let blurAmount = 4

SpriteKit childNodeWithName can't find existing node

前提是你 提交于 2019-12-11 05:58:42
问题 I have this code in SKScene: override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) { var touch: AnyObject = touches.anyObject() var point = getPoint(touch.locationInNode(self)) var name = NSStringFromCGPoint(point) for children in self.children { if (children as SKSpriteNode).name == name { println("exist!") } } var tempNode = self.childNodeWithName(name) } I see "exist!" in log, so there is a node with this name in children array, but tempNode is nil . The self

How to create transition into SKAction?

六眼飞鱼酱① 提交于 2019-12-11 05:55:22
问题 i created function that change my background color every 10 seconds and i want to add transition when its change the color of the background. Game Scene : let wait = SKAction.waitForDuration(10) let block = SKAction.runBlock({ [unowned self] in self.backgroundColor = UIColor.randomColor() }) let sequence = SKAction.sequence([wait,block]) runAction(SKAction.repeatActionForever(sequence), withKey: "colorizing") thanks for help! 回答1: You can do it like this: override func didMoveToView(view: