Hot answers tagged

20 votes
Accepted

Using L-Systems to procedurally generate cities

L-Systems, from what I can tell*, are a set of grammar-like substitution rules that you can apply recursively to get interesting, "organic" results. Plants are where L-Systems are often used, as they ...
  • 14.6k
17 votes
Accepted

How do I create a simple RPG game server?

You're on the right track. The gist of the client-server networking model is that a server is that it's a central point of knowledge that clients connect to. A game server typically contains an in-...
  • 13.3k
14 votes
Accepted

Why does Unity let you install iOS Build Support on Windows?

As far as i know when you build for IOS on windows it will generate an Xcode project that you then need to build on mac. As you can't make IOS bundles on windows the only thing you can do is to make ...
  • 3,571
14 votes

Can you show rng code running in real time in a game?

Yes, you can. There are already online platforms that are doing exactly that, by providing you the hash of the online secret key that is used as the seed for the random generation. Same seed = same ...
  • 2,385
11 votes

Train-like movement in a 2D game

I'm not used to Cocos2D engine, but I can suggest this solution for you to apply to your game. Naive implementation The simplest way to implement a train wagon can be making an object which follows a ...
  • 4,270
10 votes
Accepted

How to implement color changing fragment shader?

Here's how I would do this. First, make sure you have the object's UVs or world coords (which you can pass through from your vertex shader) available to you. If it's just a background, you could also ...
8 votes
Accepted

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

I don't think this is going to be quite as easy as you'd like, that said you should be able to copy/paste the code below to get something going. There might be a better way to approach this, but as I ...
  • 231
6 votes
Accepted

How to detect collision on specific part of the sprite node

Remember that SpriteKit's physics system is based on "SKPhysicsBody"s, which are added to "SKSpriteNode"s. Those physics bodies, however, needn't be attached to visible nodes. The simplest method is ...
  • 2,169
6 votes

Cross-platform C++/OpenGL ES development (iOS/Android)

You may find my answer to a similar question here to be helpful. You may also find it helpful to look into the source code of other solutions. The Godot Engine for example is a cross platform open ...
6 votes

Should I patent game before putting it on Apple App Store?

You can't patent a game. You might pattern a particular algorithm but it's unlikely to be of benefit to you to do so because of a couple reasons. Patents are highly specific. I was worried I was ...
  • 965
5 votes

Does SpriteKit follow the MVC pattern?

Your question is a good one. I've had exactly the same question regarding SpriteKit and have been very confused about the lack of information on the web about this. SpriteKit seems to encourage you ...
4 votes

Offset a camera/render without changing perspective

Wow that was fast. It's crazy how sometimes just writing out the question helps you figure out how to approach a solution. Here is my matrixPerspective function: ...
  • 1,901
4 votes

Android game to iOS, go with an engine?

There is no simple way to convert your java code into Unity, unfortunately. You are going to have to convert the entire code base into either C# or Javascript. Even the way you do your scenes are ...
  • 8,279
4 votes

How do I know when the app is launched, loses focus and gets focus again on mobile?

The following snippet calls EnterApplication() and ExitApplication(), for you to implement yourself. It works in Editor, on Android, and on iOS, consistently. The methods are called when the ...
  • 5,333
3 votes

Approaches for a clickable map of nations (such as a Risk game) with Spritekit

(A) If you need the countries to be sprites I would try this: Make the sprite for each country just big enough to contain them Make a UIBezierPath for each country and save that as a property of the ...
  • 131
3 votes
Accepted

Total Texture memory size iOS / OpenGL ES

On iOS it seems that you are asking for trouble when the total memory usage for your app starts approaching half of the device's total memory (1gb for iPhone 5). But there's not a completely hard ...
3 votes

Simulating Smartphones on PC with Unity

Unity Remote exists for this purpose. Quoting their description: Unity Remote is an application that allows you to use your target device as a remote control for your project in Unity editor. ...
  • 15.6k
3 votes

model view projection multiplication order

It depends on the implementation of the multiply operation. The internals will suppose an ordering within your matrices, row major or column major. If the ordering of your matrices is arranged the way ...
  • 2,363
3 votes
Accepted

Finding neighboring coordinates on offset tile map

If I understood you correctly, you only want to know whether two tiles, specified by their 2D offset coordinates, are adjacent or not. For any question related to hexagon grids, I'd recommend to ...
  • 673
3 votes
Accepted

How to make a joystick follow the touch around a starting point using atan2?

You're only getting angles in the top-right quadrant because you're taking the absolute value of dy & dx. The sign information is important for determining what quadrant atan2 should return. What ...
  • 117k
3 votes

How do I create an in-app update for a mobile game?

As Ophir Prusak points out, Apple does not allow downloading code to your app. So one possibility is that you could make your game logic and behavior entirely data-driven. Then all you do is download ...
  • 6,409
3 votes
Accepted

How to implement 'Fog of War' in SpriteKit or Cocos2D?

One option is to overlay a texture that has a blend mode of Multiply set to it over your tiles. The overlay texture would be almost black (dark shades of grey) all around, except for the area you want ...
  • 282
3 votes

Pathfinding: longest route along tiles of same type

If I am not mistaken these types of problems are usually solved by backtracking family of algorithms. I would use an algorithm similar to DFS: recursively search the solutions tree and whenever leaf ...
  • 4,880
3 votes
Accepted

How can I play user-provided music stored on the phone inside my game?

It is possible to do so. Given a directory, unity's WWW class will be able to obtain the file using the URL. You can then create a clip with that file and pass it to the audio source. Do note that ...
  • 1,401
3 votes

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

Yup! As of iOS 9, you can set a SceneKit SCNView to use a Metal renderer on devices that support it by initializing it with the SCNPreferredRenderingAPIKey key in ...
3 votes
Accepted

How to determine contact bodies when multiple bodies overlap and a third makes contact with both at the same time

I'm not really a fan of this : ...

Only top scored, non community-wiki answers of a minimum length are eligible