sprite-kit

(Physics engine for games like Sugar, Sugar) SpriteKit performance optimization for many physics sprites

懵懂的女人 提交于 2019-12-13 03:36:17
问题 I'm a iOS game developer and I saw an interesting physics & draw game "Sugar, Sugar" recently. In the game, there are lots of pixel particles (thousands of them) generated from the screen and free falling to the ground. Player can draw any shape of lines, which can guide those particles to certain cups. A image from google: I'm trying to achieve similar effect using SpriteKit with Swift. Here's what I got: Then I encounter a performance problem. Once the number of particles > 100. The CPU and

Using SpriteKit inside UIKit

Deadly 提交于 2019-12-13 03:23:52
问题 I am contemplating a simple app that has four characters that you can drag around on the screen. While dragging they "wiggle" — that's the animation. And they snap to a position if they get close enough to it... like in a puzzle. Without the animation, this is all simple in UIKit. My first thought is to render each character in its own SKView inside a plain old UIView . I could attach UIGestureRecognizers to each SKView to track tapping and dragging. But I think this implies individual

The best way to implement lives and score count in Sprite Kit (static, IoC, other?)

可紊 提交于 2019-12-13 03:16:37
问题 I have background in Java but havn't been coding in years. Lately I've taken interest to warm my coding skills again and have chosen to create learning apps for my kids in Swift. I've created basic Swift game utilizing the Sprite Kit with gameviewcontroller and multiple scenes. However I run into a basic question which is related to passing basic data such as points and lives counts from scenes to gameviewcontroller. Back in the day, I would have done it by creating a static member that would

canDisplayBannerAds = YES causes Sprite Kit app to crash

心不动则不痛 提交于 2019-12-13 02:49:53
问题 Working on my first game and trying to implement ads in to it. I've declared the following in my viewController.h #import <UIKit/UIKit.h> #import <SpriteKit/SpriteKit.h> #import <iAd/iAd.h> @interface ViewController : UIViewController <ADBannerViewDelegate> And in my implementation file I've Got the following (used because I need landscape layout) - (void)viewWillLayoutSubviews { [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"Result"]; [super viewWillLayoutSubviews]; NSError

Add UIView to back of scene in SpriteKit game

大城市里の小女人 提交于 2019-12-13 02:39:15
问题 I am trying to make a advent calendar with a snow affect in swift2. I am using the game template while using SpiteKit. Here is my code so far: GameScene.swift import SpriteKit class GameScene: SKScene { /*override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { if let touch = touches.first { let location = touch.locationInNode(self) print(location) } }*/ func test() { //Generate Doors //Initilization var adventDoors = [AdventDoor]() let offset = CGVector(dx: 10,dy: 10)

Unexpectedly Found Nil SKSpriteNode

旧巷老猫 提交于 2019-12-13 02:22:12
问题 I get the following error when there's contact between bullet and the plane. fatal error: unexpectedly found nil while unwrapping an Optional value Plane Function: func addPlane() { var myplane : SKSpriteNode? myplane = SKSpriteNode(imageNamed: "plane") let actualY = random(min: 100, max: size.height - myplane!.size.height/2) myplane!.position = CGPoint(x: size.width + myplane!.size.width/2, y: actualY) myplane!.physicsBody = SKPhysicsBody(rectangleOfSize: myplane!.size) // 1 myplane!

Unable to set the right size for the GameScene in spritekit [SWIFT]

谁说胖子不能爱 提交于 2019-12-13 02:14:01
问题 Currently I'm making a game in spritekit & swift but the problem is I've set the GameScene size with size:CGSize(width: 750, height: 1334) in GameViewController that extends the UIViewController. The reason that I had set the size to 750 * 1334 is because I wanted to publish the game for iphone 6, but the problem is the will it be displayed wrongly in 6plus or iphone 5 ? Was it the right choice to set the size ? Should I prepare the image for @2x and @3x ? Most of the ingame characters and

SpriteKit coordinate system messed up

不打扰是莪最后的温柔 提交于 2019-12-13 02:11:00
问题 In portrait mode, i created a SKShapeNode at the position of 0,0 . Yet it seems that it does not appear in the screen at all. This is the code i am using now let test = SKShapeNode(rect: CGRectMake(0, 0, 10, 10)) test.fillColor = SKColor.blackColor() self.addChild(test) The background colour white, so the shape node will definitely appear if it was on the screen Yet 0 node appears in the screen? children.count returns 1 And this is how i display the scene override func viewWillLayoutSubviews

Reloading an SKScene or View to remove iAd after In App Purchase

筅森魡賤 提交于 2019-12-13 01:43:24
问题 I've successfully removed iAds from my Sprite Kit game after an In App Purchase, but the problem is that the app needs to be restarted for the ads to stop showing. This leads me to believe that the view or scene needs to be refreshed/reloaded somehow (I've tried so many ways) for the iAds to disappear after the In App Purchase is made. The In App Purchase is made in a separate class called PurchasedViewController which I present modally. Currently, I'm trying to send a notification after the

Cannot convert value of type 'NSMutableArray' to expected argument type '[SKAction]'

佐手、 提交于 2019-12-13 01:37:57
问题 I checked my old game (made in SpriteKit) and I want to update it in Swift 2.0. When I tried to fix it, Xcode found an errors. Error is: Cannot convert value of type 'NSMutableArray' to expected argument type '[SKAction]' In code: torpedo.runAction(SKAction.sequence(actionArray)) Function: override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) { self.runAction(SKAction.playSoundFileNamed("torpedo.mp3", waitForCompletion: false)) var touch:UITouch = touches.anyObject() as