skspritenode

Swift - SKSprite Kit - Change Gamescene Variables from FileBrowser Closure

自闭症网瘾萝莉.ら 提交于 2020-08-10 19:17:40
问题 I am working on an application that uses the 'FileBrowser' CocoaPod to load files in a simulator (using the SKSprites Physics Engine) I have a function in my GameViewController that creates a 'FileBrowser' instance, then allows the user to set it's 'didSelectFile' closure like so: let file = FileBrowser() present(file, animated: true, completion: nil) fileBrowser.didSelectFile = { (file: FBFile) -> Void in print(file.displayName)} This enables me to trigger that small bit of code in the

Swift - SKSprite Kit - Change Gamescene Variables from FileBrowser Closure

*爱你&永不变心* 提交于 2020-08-10 19:16:06
问题 I am working on an application that uses the 'FileBrowser' CocoaPod to load files in a simulator (using the SKSprites Physics Engine) I have a function in my GameViewController that creates a 'FileBrowser' instance, then allows the user to set it's 'didSelectFile' closure like so: let file = FileBrowser() present(file, animated: true, completion: nil) fileBrowser.didSelectFile = { (file: FBFile) -> Void in print(file.displayName)} This enables me to trigger that small bit of code in the

Swift: No contact detection between nodes

♀尐吖头ヾ 提交于 2020-03-23 08:03:14
问题 Issue This is my code for my game. A brick falls and hits a side of a square. To differentiate what side is hit, four triangles are spawned that make the square. They are invisible from a low opacity. I am not receiving any contact between the brick node and the triangle node. The brick piece just falls right through the square. Any help? Game Code import SpriteKit class GameScene: SKScene { let basicTop = SKSpriteNode(imageNamed: "basic top"); let basicBottom = SKSpriteNode(imageNamed:

Swift: No contact detection between nodes

徘徊边缘 提交于 2020-03-23 08:03:10
问题 Issue This is my code for my game. A brick falls and hits a side of a square. To differentiate what side is hit, four triangles are spawned that make the square. They are invisible from a low opacity. I am not receiving any contact between the brick node and the triangle node. The brick piece just falls right through the square. Any help? Game Code import SpriteKit class GameScene: SKScene { let basicTop = SKSpriteNode(imageNamed: "basic top"); let basicBottom = SKSpriteNode(imageNamed:

Make SKSpriteNode flash white with SKAction colorizeWithColor

北城余情 提交于 2020-02-03 08:14:52
问题 Ok so I have a sprite thats suppose to flash white when hit by something, I'm using this SKAction *changeColorAction = [SKAction colorizeWithColor:[SKColor whiteColor] colorBlendFactor:1.0 duration:1]; What happens is the sprite flashes, but instead of white, it just turns transparent. If I use any other color like redColor, blueColor, ect.. It works perfect. How can I get it to actually turn white? Thanx for the help!!! :D 回答1: Colorize with white should give you the image's original colors.

Make SKSpriteNode flash white with SKAction colorizeWithColor

百般思念 提交于 2020-02-03 08:14:08
问题 Ok so I have a sprite thats suppose to flash white when hit by something, I'm using this SKAction *changeColorAction = [SKAction colorizeWithColor:[SKColor whiteColor] colorBlendFactor:1.0 duration:1]; What happens is the sprite flashes, but instead of white, it just turns transparent. If I use any other color like redColor, blueColor, ect.. It works perfect. How can I get it to actually turn white? Thanx for the help!!! :D 回答1: Colorize with white should give you the image's original colors.

Turning Object with SkSpriteNode

╄→гoц情女王★ 提交于 2020-01-24 20:43:11
问题 I have an image named "Ghost" and it moves throughout the screen. I want to have the SpriteNode constantly turning without being pressed on. Ghost = SKSpriteNode(imageNamed: "Ghost1") Ghost.size = CGSize(width: 50, height: 50) Ghost.position = CGPoint(x: self.frame.width / 2 - Ghost.frame.width, y: self.frame.height / 2) Ghost.physicsBody = SKPhysicsBody(circleOfRadius: Ghost.frame.height / 1.4) Ghost.physicsBody?.categoryBitMask = PhysicsCatagory.Ghost Ghost.physicsBody?.collisionBitMask =

Converting tiles to sprite nodes in XCode Swift

我们两清 提交于 2020-01-17 03:37:22
问题 I am developing a mini-game and I've drawn the map by using the program Tiled. Let's assume that I've used a tile set of three pictures; how do I 'convert' them to SKSpriteNodes? Let's say that there is one tile representing the character and three tiles representing ground. I want these four to be sprite nodes. Thanks in advance 回答1: I can't help you with the Swift version but look at the below pics to get a better understanding of what I am talking about. Create an Object Layer in Tiled.

Coordinate System in SpriteKit

断了今生、忘了曾经 提交于 2020-01-13 19:41:35
问题 I am quite confused with the spritekit coordinate system. I need clarification on two cases. Case 1: When a sprite node is added as child to the scene: SKSpriteNode * blueBall = [SKSpriteNode spriteNodeWithImageNamed:@"hRedBall.png"]; blueBall.name=@"blueball"; blueBall.size=CGSizeMake(75, 75); blueBall.position=point; //I am varying this point [self addChild:blueBall]; I have added the node at different points each time.These are the points I added the node at: (100x100)(200x200)(300x300)

Adding textfield to SKScene

不想你离开。 提交于 2020-01-12 08:49:42
问题 I am creating a game using Sprite Kit, and I want to add a textfield for players to enter their name. How can I create a textfield using Sprite Kit? I'm going to create a player object (which I already have set up) and use the name they enter and a default score of 0. Is it bad practice, or even possible, to mix UITextfields and Sprite Kit nodes? 回答1: Something like this UILabel *nameField = [[UILabel alloc] initWithFrame:CGRectMake(200, 200, 300, 100)]; [self.view addSubview:nameField]; But