sprite-kit

Node movement lag in Spritekit, Xcode

 ̄綄美尐妖づ 提交于 2019-12-11 04:24:11
问题 In my game I have a node that the player controls with the PanGesture . When the PanGesture function is called, it adds its velocity to that of the Node in question, making it move. However, I have encountered a problem where the Node (under specific yet inconsistent circumstances) moves slower and not as smoothly as intended. When I start the application it (sometimes) has the correct movement speed. As soon as I "die", and restart (remove all nodes and recognizers, restart the scene, remake

How to get SKSpriteNode name?

别说谁变了你拦得住时间么 提交于 2019-12-11 04:16:00
问题 I'm working with this code I've found and trying to figure out how to get the node names for my objects? Here's part of the code: let sprite1 = SKSpriteNode(color: UIColor.redColor(), size: CGSize(width: 30, height: 30)) let sprite2 = SKSpriteNode(color: UIColor.greenColor(), size: CGSize(width: 30, height: 30)) let sprite3 = SKSpriteNode(color: UIColor.blueColor(), size: CGSize(width: 30, height: 30)) let sprite4 = SKSpriteNode(color: UIColor.yellowColor(), size: CGSize(width: 30, height: 30

Game Center In SpriteKit Not Dismissing Leader Board

百般思念 提交于 2019-12-11 04:09:29
问题 After a lot of searching on here I finally found a way for Game Center to display in SpriteKit but now I can't get the leaderboardViewControllerDidFinish method to call. I use this code in a different app and it works fine but for some reason with the code being modified for SpriteKit its just not working. Thank you in advance! Here is a sample of my code: - (void)showGameCenterButtonPressed:(id)sender { { if ([GKLocalPlayer localPlayer].authenticated == NO) { UIAlertView *message = [

SpriteKit and particle collision

佐手、 提交于 2019-12-11 04:05:59
问题 I have a particle emitter and I would like to detect it when the particles collide some physics bodies. Is there a native way to do that in the SpriteKit API or do I need "to cheat" ? 回答1: Individual particles can not collide. Not with physics, not any other way. You do not even get any information about an individual particle - you can't access it's position, rotation, velocity .. nothing. If you wanted to "cheat" you'd have to emulate the particle emitter using sprites, and animate the

Scaling a pendulum made with SKSpriteNodes

社会主义新天地 提交于 2019-12-11 04:05:55
问题 I've got a working clock with a pendulum, but the swinging arm does not scale correctly. Here's what it looks like before scaling... And then, after scaling... The clock face scales down, and so does the swing arm (the green line), but it looks like it scales around it's center point not the fulcrum at the center of the face. I can fix that scaling by setting the swing's anchorPoint so it scales toward one end rather than the center... swing.anchorPoint = CGPointMake(0, 0.5); but doing that

How to get the original image scale from an SKTexture?

牧云@^-^@ 提交于 2019-12-11 04:05:15
问题 I'm using sprite-kit in Swift and setting up textures using the SKTexture(rect:inTexture:) function. I am not using built-in texture atlases, instead I am creating the parent texture (the texture atlas) using SKTexture(imageNamed:) . This is because I already have atlases and sub-texture positions (in pixels) in my data files, not separate images. So the .size() of the SKTexture object is correct when the image is @2x (the size is half of the pixel dimensions). I calculate the sub-rect

ins SpriteKit, “select” all the sprites my finger touches while moving

三世轮回 提交于 2019-12-11 03:59:55
问题 So I'm trying to learn SpriteKit while building what I think is a simple puzzle game. I have a 5x5 grid of SKSpriteNodes of different colors. What I want is to be able to touch one, and move my finger horizontally or vertically and detect all the nodes that my finger is touching, like if I was "selecting" them. I tried to do something like this, but it crashes the app: -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [touches anyObject]; CGPoint location =

Working with SKSpritenodes and textures

我们两清 提交于 2019-12-11 03:51:44
问题 I am trying to program in feature that allows the user to change the "Ghost" to a different image. Here is my code: Ghost = SKSpriteNode(imageNamed: "Ghost17") 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 = PhysicsCatagory.Ground |

How to give screen edge a physics body

…衆ロ難τιáo~ 提交于 2019-12-11 03:44:08
问题 I have a background sprite that I would like to give physics body. background.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:CGSizeMake(screenWidth , screenHeight)]; The problem is that the sprites are within the screen bounds and Im trying to detected collision with those sprites when they hit the edge of the screen. Instead its automatically detecting collision because my sprites are already within the physics body of the background. What do I do? Update:Above question is answered for

Where to use CGPathRelease?

限于喜欢 提交于 2019-12-11 03:35:53
问题 I am creating a line for my SKShapeNode using a CGMutablePathRef. Reading up on the usage a bit, I came across a post saying that it's important to use CGPathRelease when you're done using the path. Now I am wondering, when can I release the path? Will releasing it while the SKShapeNode still exists do any harm? Oh and, sorry if CGPathRelease isn't used anymore since the introduction of garbage collection, I couldn't find out if it still had to be used or not, so please correct me if it's not