Questions tagged [swift]

Swift is a multi-paradigm, compiled programming language.

Filter by
Sorted by
Tagged with
0 votes
0 answers
18 views

SKNodes in a grid configuration get out of place after falling to fill gaps

I am making a “simple” game where the user will “pop” blocks by tapping on “clusters” of blocks. When the user taps it destroys the “cluster” of blocks, the other blocks move down to fill in the ...
jforward5's user avatar
0 votes
1 answer
38 views

Grouping "touching" nodes of the same color together

I am trying to make a very simple game that allows the user to tap on any "block" in the scene and "pop" it. If the block is blue and touching another blue block then both blocks ...
jforward5's user avatar
1 vote
0 answers
23 views

How do I rotate OBJ submeshes relative to themselves (or arbitrary point, as opposed to relative to the whole model)?

I'm creating my own flight simulator game from scratch, using Swift and Metal, for learning purposes, and I'm wondering how I can move certain parts of my aircraft model. My model is a free OBJ file ...
Tino's user avatar
  • 11
0 votes
0 answers
43 views

INSANE Slowdown when implementing MSAA

I am trying to implement MSAA in my very simple raytracer. However, when I do, my program gets and insane slowdown. I am working in Metal, and on the Metal HUD, I can see that my frametimes drop from ...
oli2's user avatar
  • 3
0 votes
0 answers
49 views

Dynamic bodies falling onto static body tunnel through each other or fail to bounce

I have a problem with Box2D when 2 dynamic bodies fall onto a static body located below when their restitution is non-zero. They tunnel through each other instead of a rigid elastic bounce. If I treat ...
Simon Zvara's user avatar
0 votes
2 answers
200 views

How to check multiple rings of tiles around a center tile on a 2D grid

In my game project I create the terrain programmatically by creating tiles on a 2D grid as the player moves around the game map. I have it working where I select the current tile and check all 8 ...
peacetype's user avatar
  • 145
0 votes
2 answers
277 views

Quaternions distorting object in Metal

I've been trying to get rotations with quaternions to work for a while now, and I feel I am very close to it actually working but I just can't get it to work. I do not have a view matrix yet and am ...
CaptainLupa's user avatar
1 vote
1 answer
407 views

How can I prevent the camera going out of bounds?

I've been working on a Mario Bros clone for the first level, trying to learn how to make games with SpriteKit. I'm trying to use an ...
Frakcool's user avatar
  • 111
0 votes
0 answers
69 views

Best way to save screenshots in a game?

I'm making a game, and I'm adding a screenshots feature. Currently I save screenshot files to <Home Directory>/Pictures/MyGame/. However, I'm not sure if ...
user avatar
0 votes
0 answers
92 views

How to run skactions randomly

Hey guys I need some help I have 2 SkActions. ...
WHY25's user avatar
  • 11
2 votes
1 answer
152 views

A ball hits the corner slightly, where will it deflect?

I am currently making an iOS Game but I have a small problem. The game is simply a ball which you can control to avoid obstacles and find the food. When the ball hits, e.g. the top or the bottom of an ...
Merlin0216's user avatar
1 vote
0 answers
43 views

How can I remove sprites when they are outside viewport, but then add them again if I return to their location to save memory

I'm creating an open-world RPG like Neverwinter nights. But I’m worried about memory and am afraid if I just populate a huge world with physics based sprite nodes, I won't have any memory for anything ...
Mugs's user avatar
  • 111
0 votes
0 answers
46 views

Advice on how to organise the levels in a game

I'm thinking of building a 2D platformer game similar to Super Mario Bros, but I'm in the planning process and realised I don't really have a good way of storing information about each level – where ...
Frævik's user avatar
1 vote
1 answer
364 views

Why does my 3d model become invisible as I move the camera away?

I'm trying to load a 3d model from Mixamo: // let scene = SCNScene(named: "art.scnassets/ship.scn")! let scene = SCNScene(named: "art.scnassets/Ch45_nonPBR.dae")! ...
Kaizer Sozay's user avatar
1 vote
1 answer
575 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 ...
Repardeimaj's user avatar
2 votes
1 answer
41 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....
margusholland's user avatar
0 votes
1 answer
126 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 ...
JimmyK1's user avatar
2 votes
1 answer
317 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 ...
lsauceda's user avatar
  • 151
1 vote
1 answer
43 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 ...
paul_graham_for_president's user avatar
2 votes
1 answer
246 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 ...
peacetype's user avatar
  • 145
2 votes
1 answer
740 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 ...
JoeBob123's user avatar
0 votes
1 answer
116 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 ...
TommyBs's user avatar
  • 407
2 votes
1 answer
2k 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 ...
halileohalilei's user avatar
1 vote
1 answer
262 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 ...
retrovius's user avatar
  • 117
0 votes
1 answer
1k 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 ...
retrovius's user avatar
  • 117
1 vote
0 answers
394 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 ...
Sasha Nodia's user avatar
2 votes
1 answer
651 views

How do I apply touches to images, using Swift? [closed]

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. <...
Hoang Anh Nguyen's user avatar
2 votes
1 answer
145 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 ...
GameNoviceDev01's user avatar
1 vote
0 answers
380 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 ...
WokerHead's user avatar
  • 111
3 votes
1 answer
522 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 ...
iGetIt's user avatar
  • 131
3 votes
1 answer
968 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 ...
Hilarious404's user avatar
0 votes
1 answer
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 ...
OtakuFitness's user avatar
2 votes
0 answers
371 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 ...
NightMare's user avatar
0 votes
0 answers
142 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 ...
TommyBs's user avatar
  • 407
1 vote
0 answers
717 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? ...
Michael Cube's user avatar
1 vote
1 answer
2k 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 ...
Lirf's user avatar
  • 15
1 vote
1 answer
526 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 ...
panzerblitzer's user avatar
1 vote
2 answers
3k 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 ...
ndbroadbent's user avatar
5 votes
1 answer
4k 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 ...
ndbroadbent's user avatar
0 votes
1 answer
126 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: ...
Alfie Hanssen's user avatar
0 votes
1 answer
1k 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 ...
fridgemagnet's user avatar
1 vote
1 answer
601 views

Collision Between SKSpriteNode and SKShapeNode

I'm trying to create a collision between two objects. One is a SKSpriteNode and the other is a SKShapeNode. The code I have so ...
WHY25's user avatar
  • 11
1 vote
0 answers
533 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: ...
Ramy Al Zuhouri's user avatar
4 votes
2 answers
2k 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: ...
Ramy Al Zuhouri's user avatar
2 votes
1 answer
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 ...
Ramy Al Zuhouri's user avatar
0 votes
1 answer
113 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 ...
xdevx32's user avatar
1 vote
0 answers
240 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, ...
naivedeveloper's user avatar
2 votes
1 answer
7k 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 ...
Ramy Al Zuhouri's user avatar
-1 votes
1 answer
390 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 ...
Christian Kreiter's user avatar
2 votes
1 answer
461 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 ...
MassivePenguin's user avatar