Questions tagged [swift]

Swift is a multi-paradigm, compiled programming language.

Filter by
Sorted by
Tagged with
3
votes
1answer
327 views

How to determine the angular velocity needed move an object to a given position

I am trying to move two lines joint to a fixed position sprite in a way similar to that of a pendulum. I would like the lines to swing from end to end each time. The image below shows what I want to ...
1
vote
1answer
288 views

calculating the trajectory of an object in SpriteKit when an impulse is applied to it

I want to make a trajectory line of little balls of where the object is going to go after an impulse, sort of like what is in Angry Birds. I did some research and it seems that the physics in ...
3
votes
1answer
1k views

How can I avoid a delay with continues touch detection in swift?

I want control a character on my screen with a continuous swipe gesture. As soon as I do a swipe +x or -x my character moves ...
0
votes
0answers
13 views

making an SKSpriteNode collide with another SKSpriteNode through the use of a projectile image

i am having a lot of troublefiguring out why my projectile will not shoot the image of luke. I have tried many different methods to try and counteract this but none of the strategies have seem to ...
0
votes
0answers
20 views

How to match user drawing with predefined drawing model?

i am trying to develop image recognition iOS app , i will have one reference image , and user has to draw something one screen and when user release finger , then i will convert his drawing into <...
4
votes
2answers
1k views

How to add a bump map in scene kit?

I'm trying to draw an Earth, as I've found the textures in this site: http://planetpixelemporium.com/earth.html I loaded the diffuse, specular and bump maps: ...
2
votes
1answer
28 views

tvOS game launch image shows on simulator but not on device

I’ve set up a launch image in XCode and it does show up in the simulator, but on the Apple TV it just displays a blurry gray background. The image is the correct size and doesn’t have any transparency....
2
votes
1answer
318 views

How do I apply touches to images, using Swift?

I need code this game for iOS, using Swift; but I don't know how to apply touches to images, using Swift. My attempts thus far have failed; touch!.view != image. <...
0
votes
0answers
30 views

Move SKEmitterNode along with the trail that it creates

In Swift in SpriteKit, I have a SKEmitterNode that I have set up to make trails following the player. I have the target set to self, the scene so that it will make these trails when moved. I would ...
0
votes
0answers
105 views

Swift Error “unrecognized selector sent to instance 0x7f96875356e0”

This is the function i am trying to spawn obstacles in my game ...
0
votes
1answer
34 views

Swift get the true date

I have a game and want to reward the user for going on every day. I want to be able to get the true date somehow. I do not want the device date, because the user could just change it and get free ...
0
votes
0answers
25 views

Managing character movement in 3D in AR

I'm working on an ARKit project where I need to manage the movement of an object (white box) on a plane (blue square). The characteristics of the environment are : The box can move only in 2D along ...
0
votes
1answer
46 views

Implementing score relative to total game time

How would one create score dependent on total time in game? I would like the score to count by 1000+ each second the game is running for. Later I am going to add some coins which will give my total ...
1
vote
1answer
130 views

Use GKEntity's component(ofType:) with inheritance

I'm writing a SpriteKit game in swift and making use of GameplayKit's entity-component system. There are many components that do different stuff but share the same methods in which they do it, so I ...
1
vote
1answer
40 views

UnrealEngine4 “backwards compatilibility”: Can I view a site that uses Unreal Engine4 on a very old laptop and still see in high definition?

Backwards compatible? The project: I want to render a high definition model on my personal website such that it'll be rendered in the highest definition possible on any device, from a 20-year-old ...
2
votes
1answer
88 views

Calculating the difference between two numbers using exponential growth

I think this is a very basic game programming question, but I am bad with math and new to programming & game programming so I'm looking for some advice. I'm making a 2D sprite game for iOS. Every ...
1
vote
2answers
298 views

Where should I save game object's attributes (hp, score) in Swift?

Scenario: I have a game with several game objects on screen. Each can have different score and hitpoints. When I use collision detection for cannonball vs. ship (example) I need to know which ship is ...
0
votes
1answer
70 views

Breaking up a map so countries can be colored separately in Spritekit

I'm currently trying to build a little strategy game where players take control of countries on an world. Each player's countries are represented by having a different color background but as each ...
0
votes
1answer
239 views

How to assign a button in the main storyboard to launch the GameViewController.swift file

I am quite new to swift and I have constructed a main menu in the main.storyboard file, how do I assign the 'Play Now' button to launch the GameViewController.swift file where I actually plan to ...
1
vote
1answer
398 views

SpriteKit and Swift or Objective-C [closed]

As a newbie to iOS programming, I'm wondering which of these would be more conducive to the type of game I want to program. I've been tasked to program an iOS game for my company. They asked me to do ...
1
vote
1answer
131 views

How can I make a sprite slow down to the speed of another sprite while following it?

I'm making a SpriteKit game where two SpriteNodes are in a maze. That maze is represented as a grid. One sprite (A) travels faster than the other (B). Items randomly pop up, and the sprites have to ...
2
votes
1answer
1k views

Get the up vector of the camera in ARKit

I'm trying to get the four vectors that make up the boundaries of the frustum in ARKit, and the solution I came up with is as follows: Find the field of view angles of the camera Then find the ...
0
votes
1answer
267 views

Don't know what to do with XML file and Spritesheet (Swift 3)

I'm new to spritesheets and game development in general. I have two files: 1) a .png spritesheet with tons of sprites and 2) a companion XML file with coordinates, anchor points, image names, and ...
1
vote
0answers
277 views

One SKSpriteNode with multiple PhysicsBodies?

I am making a game similar to Lunar Lander, when you land with your ship on different objects, etc... The issue I am having is that I have a Player SKSpriteNode (my Ship) with a slightly complex ...
2
votes
1answer
80 views

How to move sprite as if not rotated when rotated 90 degrees?

We're making a Tetris like game and need help rotating shapes. Moving the shape works when there is no rotation. However, after rotation, snapping the shape to the grid fails because the vector ...
2
votes
0answers
205 views

Swift gamedev options for linux [closed]

I recently tried out Swift. I found it to be awesome. But I'm unable to find any libraries for game development as I'm on Linux. Everything seems to be made for MacOS & iOS development. There ...
1
vote
0answers
276 views

Swift Spritekit: Create realistic driving sprite

How would I go by creating a realistic driving experience? I'm using iOS Swift 3 with SpriteKit using the functions applyForce to accelerate when I click the gas button and when braking I add ...
1
vote
2answers
2k views

How can I create a “wireframe” texture for a sphere in SceneKit?

I've been struggling to figure this out. I would like to have a sphere in SceneKit that looks like this: I think the easiest way would be to create a mostly transparent texture with the wireframe ...
2
votes
1answer
647 views

How can I create the water-like blur effect in Chameleon Run using SpriteKit and Unity?

As the character in Chameleon Run runs, a water-like blur effect is created. I would really appreciate some guidelines on how I could create this effect in SpriteKit and Unity. Please see the image ...
0
votes
1answer
1k views

The object can't rotate around z axis in SceneKit

I am doing an app with a functionality like a 3D compass, it can point to the direction where I want. The code is ...
0
votes
1answer
78 views

Should the Sprites in my Boids implementation be backed by model objects?

This question is about the proper way to architect an implementation of Craig Reynolds Boids algorithm. I have an Agent object like this: ...
0
votes
0answers
118 views

Testing for connected maze cells

I'm currently in the middle of writing a game where there is a maze. The maze itself is already drawn ok, and once I have the layout I randomly rotate all the pieces. I have a 'start' cell that is a ...
1
vote
0answers
664 views

Fatal error: unexpectedly found nil while unwrapping an Optional value [closed]

I am trying to run this code but I keep on getting this error: fatal error: unexpectedly found nil while unwrapping an Optional value I don't understand why I'm getting it. Any hint? ...
1
vote
1answer
1k views

Tile based movement with SKAction (Xcode 8, Tile Map)

I am trying to make a game where the Hero can move like in Pokemon with SKActions. But the movement looks unprofessional and have delays. How can we handle to move the Hero smoothly with SKActions ...
0
votes
1answer
449 views

Collision Between SKSpriteNode and SKShapeNode

Im trying to create a collision between to objects. one is a SKSpriteNode and the other is a SKShapenode. the Code I have so far for Contact is : func didBeginContact( contact: SKPhysicsContact) { ...
5
votes
1answer
3k views

How do I pixelate a scene with SceneKit and Metal, in Swift?

I managed to get pixelation working by using the OpenGLES2 rendering API, and a CIFilter. But it was way too slow, so I want to use the Metal API and just have a very simple filter that pixelates ...
0
votes
1answer
71 views

Does Apple allow customers to play over Bluetooth?

I'm a beginner in app development so sorry if my question is cheap :( I wanted to start developing a card game and i was wondering if apple allows customers to play over Bluetooth or not ( on ...
0
votes
1answer
745 views

CPU and RAM usage in OpenGL too high in Swift

My game is set up so the the display controls the game loop, usual in Cocoa. The callback function calls run() which is this. The thing is, the thread running the ...
3
votes
1answer
492 views

Get Stencil buffer working iOS OpenGL ES 2.0

I have been trying to get this work but either get black screen or reporting error when using XCode to analyze the GL code like below. Any help appreciated. I am using Swift here if that making a ...
1
vote
0answers
451 views

Failed to pass uniform in Metal shader modifier

I'm trying to write a simple shader able to pass the color to be used for drawing in the fragment shader, through a uniform. I load the shader modifier and pass the uniform: ...
2
votes
1answer
2k views

Is it possible to use Metal and SceneKit at the same time?

All the tutorials that I've found online speak about using Metal alone, without any other supporting library. But I don't understand if it's possible to create a SceneKit game and then use a Metal ...
-1
votes
1answer
464 views

Fix buttons on screen

I've added buttons and SKCameraNode for my player. I got problem. When player moving left/right/jump all buttons dont follow for him. UPDATE class GameScene: SKScene, SKPhysicsContactDelegate { <...
0
votes
1answer
103 views

How can I increase the hit range of a node?

How can I set the radius or the hit range of a node initialized with a texture? Of course I can do that with increasing the size of it, but actually I want to do this without resizing the picture ...
1
vote
0answers
201 views

How do I simulate vehicle movement in a non-gravity environment (e.g., space)?

As a series of small experiments, I've began to tinker with game development, specifically using SpriteKit and Swift. I'm looking to simulate a body moving through a non-gravity environment, ...
1
vote
1answer
6k views

Why is SCNNode.rotation property a four dimensional vector?

I don't understand why SCNNode's rotation property is a SCNVector4 instead of a SCNVector3. The documentation states that: The four-component rotation vector specifies the direction of the rotation ...
0
votes
1answer
137 views

How to use objects with different attribute values in Swift?

I think this is a really basic question and to make it easier to understand what I do not understand, I use the following scenario. Scenario: I have two or more ships in my game. They should have ...
2
votes
1answer
250 views

Pathfinding: longest route along tiles of same type

I'm programming a simple tile-based puzzle game, and I've gotten stuck trying to work out a pathfinding algorithm. Here's how the game is set out: The game board is (arbitrarily) 8 tiles wide by 8 ...
-1
votes
1answer
308 views

SceneKit – White layer covering my tube

I have a simple tube node in my scene that isn't displaying properly. When I rotate it to face the camera, more than half of it is covered by some invisible sheet. When I rotate the tube enough, it ...
1
vote
1answer
181 views

How to reregister gamecontroller changedvalue handler upon game scene reload

I'm working on a tvOS game that uses the siri gamepad controller. Everything works fine the first time out. If the user loses the round I reload the same scene using presentScene. After reloading the ...
1
vote
1answer
944 views

problem with SCNTransaction in Scene Kit

I'm trying to move an object over a period of ten seconds from y coordinate 0 to y coordinate 10. the object is created at y coordinate 0. The problem is when the animation starts, the object pops ...