sprite-kit

Sprite Kit touchesbegan: delay/lag

我是研究僧i 提交于 2019-12-22 12:19:56
问题 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"touch"); ... } I have a really simple problem that I can't find any answers to. Most of the time, when I tap the screen, the nslog executes immediately. However, about 1 in 5 times, there is a half second pause before the message displays. I'm making a game and I need the touchesbegan to execute immediately. Can anyone tell me what I'm doing wrong? BTW, the framerate is a mostly constant 60 fps. 来源: https:/

Swift Displaying Game Center Leaderboards

风流意气都作罢 提交于 2019-12-22 11:08:36
问题 Right now I am trying to make a leaderboard I created show up. The player is authenticated just fine, but when the game center window opens it is very strange. Here is a picture: Here is the code I am using to display this image: override func touchesBegan(touches: NSSet, withEvent event: UIEvent) { self.showLeaderboard() } func showLeaderboard() { var leaderView = UIViewController() var leaderViewController = GKGameCenterViewController(rootViewController: leaderView) leaderViewController

SKTexture get image name

杀马特。学长 韩版系。学妹 提交于 2019-12-22 11:06:48
问题 Is there possible to get current image name from SKTexture from SKSpriteNode? I am a new in SpriteKit and I'm writing a little game. I need to detect when ninja will hit enemy. Something like this I am doing SKAction like - (void)setUpHit { SKTextureAtlas *hitAtlas = [SKTextureAtlas atlasNamed:@"Ninja_hit"]; SKTexture *hit1 = [hitAtlas textureNamed:@"Ninja_hit_1"]; SKTexture *hit2 = [hitAtlas textureNamed:@"Ninja_hit_2"]; SKTexture *hit3 = [hitAtlas textureNamed:@"Ninja_hit_3"]; SKTexture

Fill SKShapeNode with pattern image

梦想与她 提交于 2019-12-22 11:05:15
问题 I'm trying to fill a SKShapeNode with an Image/pattern but I'm still unsuccessfull. Can you help me solving this or giving me an alternative? I want to create a collidable custom shape (from any SpriteKit kind) filled with a pattern image. I've tried the following: UIBezierPath *path = [[UIBezierPath alloc] init]; [path addArcWithCenter:CGPointMake(0.0, 0.0) radius:50.0 startAngle:0.0 endAngle:(M_PI*2.0) clockwise:YES]; SKShapeNode *shape = [[SKShapeNode alloc] init]; UIImage *patternImg =

Adding an SKScene to a UIViewController?

我是研究僧i 提交于 2019-12-22 11:01:01
问题 I just created a new UIViewController in interface builder. It is segued to from a UITableViewController (cell). I now want to work with an SKScene inside this UIViewController . How is this accomplished? And for a side-note... If the SKScene takes up the entire UIViewController.view can you overlay UIKit objects on top of the scene? Or is it better to create a separate UIView inside the UIViewController.view to hold the SKScene , then layout the UIKit objects around this separate UIView ,

Collide type source error - spritekit swift game

给你一囗甜甜゛ 提交于 2019-12-22 10:59:01
问题 So I have adjusted my games ball type from a shape to an image which forced me to redo the physics of my game. I am new to swift and have struggled with fixing my collisions in my swift game. class GameScene: SKScene, GameDelegate, SKPhysicsContactDelegate { var ball: Ball! let ballSpeedX = CGFloat(500) //ball = Ball(imageNamed:"colorBall.png") enum CollisionTypes: UInt32 { case Floor = 1 case Ball = 2 } // board let boards = Boards.make(CollideType.BoardStart.rawValue) var lastBoard: SKNode?

SpriteKit SKPhysicsJointFixed odd behaviour

青春壹個敷衍的年華 提交于 2019-12-22 10:51:52
问题 I am trying to connect together two SKNodes which both have equal size circular physics bodies. They are positioned so as to be touching each other, and I want them to be locked together. From the documentation, it sounds like I want a SKPhysicsJointFixed , and I have tried creating one with the anchor point being the midpoint between the two nodes - like this: let fixedJoint = SKPhysicsJointFixed.joint(withBodyA: atom1.physicsBody!, bodyB: atom2.physicsBody!, anchor:midPoint) but this causes

Make edges of SKSpriteNode look smooth after rotation

百般思念 提交于 2019-12-22 10:40:04
问题 I create a SKSpriteNode like that: var shape:SKSpriteNode = SKSpriteNode(color: UIColor.redColor(), size: CGSizeMake(CGFloat(sizeOfShape), CGFloat(sizeOfShape))) How can I achieve, that a SKSpriteNode has still smooth edges, after I've rotated it. Currently, it looks like that: As you see, the edges are jagged. 来源: https://stackoverflow.com/questions/25532760/make-edges-of-skspritenode-look-smooth-after-rotation

Sprite-Kit Change Image of Node when screen gets touched

浪子不回头ぞ 提交于 2019-12-22 10:38:22
问题 There is a hero that is controlled by tapping on the screen. I want the hero too look a little different every time the screen gets touched. What I did is setting up two images that are a little different. I want the image of the hero to be changed when there is a touch event. Until now I set up an array to save the information in but it kinda won't work out: NSMutableArray *heroFrames = [NSMutableArray array]; NSString* textureName = nil; if (UITouchPhaseBegan) { textureName = @"hero1.gif";

Shoot from rotating body

前提是你 提交于 2019-12-22 10:36:15
问题 I have a rotating enemy body that shoots bullets. It's working pretty good, but it appears to fire in all directions except straight down. It's been a while since I took trig, and I think I'm forgetting something. Do I have to check the rotation of the enemy? SKAction *shoot = [SKAction moveTo:CGPointMake(2000*cosf(enemy.zRotation),2000*sinf(enemy.zRotation)) duration:5]; SKAction *remove = [SKAction removeFromParent]; [bullet runAction:[SKAction sequence:@[shoot,remove]]]; 回答1: Here is some