sprite-kit

Swift Sprite Kit In App Purchase

ぃ、小莉子 提交于 2020-01-13 07:16:18
问题 I have a button in an SKScene (using Swift) -- "Add Puzzles" When the user clicks this button, I want to go to a UIView Controller or UI Scene so that I can implement In App Purchase code... (SkScenes are subsets of UIViews and cannot run the code...) Does anyone have a basic idea how to do this... I am a little inexperienced at this... I have used cocos2d and now Sprite Kit and have always set everything up manually and have very little experience with .xib files and view Controllers... Does

Add ADBannerView to a SKScene

别等时光非礼了梦想. 提交于 2020-01-13 07:04:24
问题 I'm trying to add an iAd banner to my game over scene, but I don't know how to add UIView to an SKScene. The app view controller is: - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; // Configure the view. SKView * skView = (SKView *)self.view; skView.showsFPS = YES; skView.showsNodeCount = YES; // Create and configure the scene. SKScene * scene = [GameOverScene sceneWithSize:skView.bounds.size andScore:0]; scene.scaleMode = SKSceneScaleModeAspectFill; // Present the scene.

Add ADBannerView to a SKScene

落花浮王杯 提交于 2020-01-13 07:03:08
问题 I'm trying to add an iAd banner to my game over scene, but I don't know how to add UIView to an SKScene. The app view controller is: - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; // Configure the view. SKView * skView = (SKView *)self.view; skView.showsFPS = YES; skView.showsNodeCount = YES; // Create and configure the scene. SKScene * scene = [GameOverScene sceneWithSize:skView.bounds.size andScore:0]; scene.scaleMode = SKSceneScaleModeAspectFill; // Present the scene.

Can I move dynamic physics bodies using SKAction when only contact detection is needed?

蓝咒 提交于 2020-01-13 06:28:06
问题 I am looking at tutorial where things are defined like this: planes are sprites with dynamic physics bodies plane moving is done with actions by following the path there is contact detection between bullet and plane bullet is sprite and it has physics body set to be static (which is little unusual in my opinion) Here is the link to tutorial for more information. Questions: When we use actions to move physicsBodies is there a difference how we set body's dynamic property? Because bullet is

Add custom “number” images to SKLabelNode in as a Score in SpriteKit with Swift

邮差的信 提交于 2020-01-13 05:50:12
问题 I basically want to add custom font numbers (with images) in Singles and add them for my score in my game with SpriteKit. This is the font image style They are numbers from 0 to 9 I have been trying to figure this out for a while. I'm not sure if you can add it to SKLabelNode or if you would have to make it in a class. 回答1: SKLabelNode would not allow for bitmap fonts. If your custom font was TTF, you would be able to use the custom font with SKLabelNode . An explanation how is here:

Memory Increase in SpriteKit even though removeAllChildren called

故事扮演 提交于 2020-01-13 05:10:08
问题 I've been trying to fix a huge memory increase in SpriteKit for many weeks now but have found no solution. I have tried just about every method that I've come across online for managing memory in SK but am still having troubles. Here's my situation: I first present the SKScene "HomeScreen" and from there I am changing Page scenes with a UIButton in my View Controller like so: func nextPage(sender: UIButton) { pageNumber = pageNumber + 1 let switchPage = SKTransition.crossFadeWithDuration(3.0)

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

How do I create a HUD on top of my Scenekit.scene

青春壹個敷衍的年華 提交于 2020-01-12 07:06:08
问题 I'm experimenting with Swift and Scenekit. Building a Mac OS X app. It seems quite easy to get a 3d-scene working. But what is scene without some kind of 2D hi-score, radar display, speed indicator, etc? I would expect a SpriteKit-scene to seamlessly integrate into a SceneView but I don't find the documentation very clear about this.. The most obvious and only way I can think of is to position a SKView over a SceneView and render each separately. But is there a more elegant way? 回答1: try

(Swift SpriteKit) Rotate sprite in the direction of touch

自作多情 提交于 2020-01-12 05:38:06
问题 On the screenshot provided, the red arrow and cross are just for demonstration purposes and are not in the game. I would like the sprite of the spaceship to face the direction of the ball it shoots. Link to image Here is my current code for touch location override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { /* Called when a touch begins */ for touch in touches { let location = touch.locationInNode(self) var bullet = SKSpriteNode(imageNamed: "bullet") bullet.position

Converting radian angle to CGVector

独自空忆成欢 提交于 2020-01-12 05:31:46
问题 Using Sprite Kit I am trying to set an SKPhysicsBody moving according to a given angle, so for example if you wanted the sprite to travel to the right you would specify 1.571 radians. To turn the specified angle into a velocity I am using the method below to convert radians to a CGVector . The ORIGINAL version that I implemented from memory has the strange effect of offsetting all the angles by 90degrees. (i.e. if 0 degrees is used the sprite moves right (just like it would if you specified