sprite-kit

Detecting collisions in sprite kit

旧城冷巷雨未停 提交于 2019-12-27 12:21:34
问题 I'm trying to make a simple game with sprite kit. The basic idea is that there is one player who can jump to avoid blocks. But i have a problem I don't know how to make it that when the player hits the block the player disappears and the blood animation starts. First of all i don't understand what this code does that I found on apples website. static const uint32_t blockCategory = 0x1 <<0; static const uint32_t playerCategory = 0x1 <<1; Than i am calling the didBeginContact function and put a

iOS 7 Sprite Kit freeing up memory

一个人想着一个人 提交于 2019-12-27 11:59:38
问题 I am building an iOS game aimed for the new iOS 7 and Sprite Kit, using emitter nodes and physics to enhance gameplay. While developing the app, I ran into a serious problem: you create your scenes, nodes, effects, but when you are done and need to return to the main screen, how do you free up all the memory allocated by these resources? Ideally ARC should free up everything and the application should get back to the memory consumption level it had before creating the scene, but this is not

how to have a enemy be added in every 10 seconds and have this enemy track your location and follow it

狂风中的少年 提交于 2019-12-25 19:41:36
问题 im currently working on an app in which your player which is a small round ball, gets dragged around the screen by your finger. Then every 10 seconds a enemy ball gets added in which automatically tracks your ball and follows it until it runs into it. this is the code I have for this so far. you can drag your ball around the screen, bu the enemy ball which is only showing up as a red x even though its file is in the assets gets spawned every frame and they just move to the position of where

Scale sprite kit game for all devices

橙三吉。 提交于 2019-12-25 18:59:10
问题 When creating my game in spriteKit I used the game size 1080x1920. Now however If I am to run it on Ipad it looks bizarre. Is there an easy fix? I am simply worried that my app will get rejected. Thank you in advance? 回答1: When you present the scene's you also set the aspect ratio. example : if let scene = SKScene(fileNamed: "GameScene") { // Set the scale mode to scale to fit the window scene.scaleMode = .aspectFill // Present the scene view.presentScene(scene) } There are 4 different aspect

SpriteKit Objective-C: programming directional pad controls

江枫思渺然 提交于 2019-12-25 18:16:49
问题 so let me get this straight: what I'm trying to implement is controls for my SpriteKit game in the form of a directional pad. I want it to work the way so that you, for instance, can hold a button, then slide your finger to another button, so that the first button gets released, and the other button gets pressed (just like it would on a physical game controller, for example). I saw that this was implemented on many existing games (Carmageddon, Minecraft PE), so it is possible for sure. What I

Update Function Does Not Keep Up With Moving Sprite

点点圈 提交于 2019-12-25 16:51:42
问题 I have two sprites which a flush against each other. I'm moving one of the sprites around using a SKAction and moving the other sprite using the update function. Every time the update function is called, it calculates the position the second sprite needs to be at so that it continues to be flush against the first sprite. However, it seems the update function can not move the second sprite fast enough, as a gap appears between the two sprites. I assume the SKAction repositioning of the first

ConvertPointToView Function not working in Swift Xcode 7 Beta

流过昼夜 提交于 2019-12-25 12:00:12
问题 So I reverently updated to Xcode 7 Beta and I'm somewhat unsure as to whether that is pertinent information but I figured I'd mention it anyway. My issue is that when I use the convertPointToView() function, it calls for an argument of type SKScene whereas (obviously) I want to it to take a point. I have another class which doesn't inherit SKScene where I want to use this function and it errors with "use of unresolved identifier convertPointToView" (I am importing SKScene). I find this to be

How to create multiple sprites(nodes) with the same texture that will automatically generate a new when one node is removed?

老子叫甜甜 提交于 2019-12-25 09:13:50
问题 I'm trying to create a game where the user can swipe a node and once it's swiped a new node will be created at the bottom of the screen and push all other nodes up, kind of like a reverse Tetris. Here is a very basic image to give you an idea: I've be able to figure out how to swipe the node off screen but can't seem to figure out how to have all the other nodes move up a row and have a new node created at the bottom. I tried doing an "addChild" for the node I just swiped so it can appear

Sprite velocity/speed is varies on different devices

假装没事ソ 提交于 2019-12-25 09:10:19
问题 I am using the code below to move my sprite from one position to another. let screenScale: CGFloat = UIScreen.mainScreen().scale var travelSpeed: CGFloat = 20*screenScale let displacement = CGVector(dx: destination.x-enemy!.sprite.position.x, dy: destination.y-enemy!.sprite.position.y) let radius = sqrt(displacement.dx*displacement.dx+displacement.dy*displacement.dy) let normal = CGVector(dx: displacement.dx/radius, dy: displacement.dy/radius) let impulse = CGVector(dx: normal.dx*travelSpeed,

Sprite velocity/speed is varies on different devices

别来无恙 提交于 2019-12-25 09:08:05
问题 I am using the code below to move my sprite from one position to another. let screenScale: CGFloat = UIScreen.mainScreen().scale var travelSpeed: CGFloat = 20*screenScale let displacement = CGVector(dx: destination.x-enemy!.sprite.position.x, dy: destination.y-enemy!.sprite.position.y) let radius = sqrt(displacement.dx*displacement.dx+displacement.dy*displacement.dy) let normal = CGVector(dx: displacement.dx/radius, dy: displacement.dy/radius) let impulse = CGVector(dx: normal.dx*travelSpeed,