Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [swift]

Swift is a multi-paradigm, compiled programming language.

-1
votes
0answers
14 views

Swift Score Function - Increment score every 0.25 seconds by 100

so I want to increment my score by 100 every 0.25 seconds, this is what I have so far and it's not working at all! ...
0
votes
1answer
25 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 ...
0
votes
0answers
20 views

Fragment shader out of sync with vertex data

I'm writing a macOS game using Metal. I have a small visual glitch that causes me a lot of headache. The game has two kinds of game objects: The creatures, which move along the playfield (their ...
0
votes
0answers
35 views

Player name / health bars in scenekit

i'm working on a game right now in SceneKit and swift. it's a multiplayer game with the camera fixed in an overhead / isometric view. I need to now add health bars, player names etc attached to the ...
1
vote
1answer
65 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 ...
0
votes
0answers
7 views

Swift: How do I reference an object through its PhysicsCategory?

I'm trying to create a game where the user can change colors, but if they collide with a block of a different color they lose. Is it possible to test the color attribute of a an object through its ...
1
vote
1answer
39 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 ...
0
votes
0answers
27 views

Why SpriteKit game is loading too long?

I have a game which is written using SpriteKit. In this game I need huge amount of texture (about 1000) for animation. I store all of these textures in a texture atlas. When I launch my game, it's ...
0
votes
0answers
56 views

Swift: SIGABRT error when Performing Segue in an SKScene

In the game I am making, I perform a segue from the view controller with my SKScene to the view controller with a UIView when you die. When I die, I make an action to make a fading up alpha of red ...
2
votes
1answer
74 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 ...
0
votes
1answer
187 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 ...
0
votes
0answers
294 views

swift spritekit how to rotate a node so it is always positioned either vertical or horizontal once

I am writing a simple tvOS game using swift 4 and sprite kit. I would like some help on how to rotate a node either be standing straight up and down vertically with the top of the node always on the ...
0
votes
1answer
58 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 ...
2
votes
1answer
749 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 ...
1
vote
1answer
116 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 ...
0
votes
0answers
70 views

Efficiently creating and managing a very large sized tileMap

I am making a 2D JRPG built onto a Birds-eye tileMap and I cant quite wrap my brain around how I would do it efficiently I would like to use 50X50 chunks that are rendered around the player in the 4 ...
0
votes
1answer
193 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 ...
0
votes
0answers
87 views

Custom health bar/loading bar

I am trying to create a custom loading bar/health bar. Is there any way to create something like this? https://vimeo.com/232305635 Can you point me in the right direction? Which functions will I ...
1
vote
0answers
194 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
209 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. <...
3
votes
1answer
71 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 ...
1
vote
0answers
207 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 ...
0
votes
0answers
49 views

given 4 points on a textured sphere extract a 2d plane and it's projected texture

Setting the scene I'm working on a feature in scenekit where i have a camera at the center of a sphere. The sphere has a texture wrapped around it. Let's say it was a 360 degree image captured inside ...
4
votes
1answer
255 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 ...
2
votes
1answer
523 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
915 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 ...
1
vote
0answers
162 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 ...
0
votes
0answers
114 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
575 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 ...
1
vote
1answer
343 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
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 ...
5
votes
1answer
2k 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
67 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
1answer
599 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 ...
0
votes
1answer
393 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) { ...
1
vote
0answers
397 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: ...
3
votes
2answers
863 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
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 ...
0
votes
1answer
95 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
175 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
5k 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 ...
-1
votes
1answer
267 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 ...
3
votes
1answer
233 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
368 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 { <...
1
vote
1answer
167 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 ...
0
votes
1answer
70 views

Resources for making iPhone apps in C++? [closed]

I would like to start making games for the iPhone and I only know C++. I have picked up a book on Swift development, and through my research I have found it is possible to create iPhone games through ...
-2
votes
1answer
347 views

Is it possible to use Box2D or Chipmunk in Swift & Cocos2d?

I am new to iOs programming. I wonder whether it is possible to use Box2D physic engine in Cocos2D with Swift. I am asking because I started to learn Swift. And I create Xcode project from ...
3
votes
1answer
429 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
113 views

swift fast enumeration on MDLAsset not working

I load an MDLAsset from my main bundle and get an compile error when fast iterating the asset object. Type 'MDLAsset' does not conform to protocol 'SequenceType' ...