17

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-memory world representation, a list of connected players, a game loop (with e.g. player control handler, a physics engine & AI). You'll also need a ...


11

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 just use fragment coords (gl_FragCoord). For instance, let's say we're using UV coords. A fragment shader with only: gl_FragColor = vec4(vec3(uv.x),1.0); will ...


8

This is a very interesting topic. You can build the water effect using SpriteKit and its integrated physics engine. Step 1 Create a Physics World Create many little circular SKSpriteNode(s), each one will have a circular physics body matching the graphics representation Step 2 Then every frame you'll need to: Draw all the sprites on a buffer Apply a ...


6

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 to put all of your Model-View-Controller code into the same class (your SKScene subclass), which is really confusing to me. How would you ever build a game of ...


6

To expand on Josh Petrie's answer, finding the angle of the foot is also pretty straightforward. The angle of the feet is equal to the angle of the inclined surface. Since we conveniently have two points on that slope, we can find the angle of inclination (it's also possible to use two corners of the slope's triangular shape, but gradual slopes would ...


5

There are simple solutions and tricks you can use (for example, if your slopes will all be a fixed angle, just author additional sprites for sloped movement and idle, provide a mechanism for your game code to know if you are on sloped surface, and render accordingly -- this is usually what older sprite-based games did). A general solution, expanding on ...


5

To get the complete bounding rectangle of a node and its child nodes you use the calculateAccumulatedFrame method. It's a member of SKNode. I ran into this when adding my SKSpriteNodes to separate SKNodes as layers for parallax and HUD elements. I kept getting (0,0) width/height for my bounding rect on the SKNode, and I found this. It returns a CGRect, and ...


5

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 to create a SpriteNode with no actual sprite or visible body, add it as a child to the area you want on the visible shape, and categorize it differently from ...


5

As a former police officer I can offer some insight into how it really works, which might help refine your process. Divide your area up into grids and assign a car to patrol in that area, the areas may overlap a bit but the aim is to ensure a geographic spread. This reduces the problem that Alex's graphic can show - that you get two cars essentially ...


4

One method is to have the head define a trail as it moves and position all other nodes at positions along this trail. In this method you need to define the position of the body parts as a constant distance along the snake from the head. So on each frame you want to; update the position of the head. add the current position of the head to a list of ...


4

iOS 9 actually introduces a GameplayKit framework that includes State objects. This link shows you the implementation of their GKState class. It inherits from NSObject, but not from any SpriteKit node class, or any SpriteKit class at all. The thing to remember is that SpriteKit is all about drawing and physics simulation. SpriteKit tends to confuse the ...


4

How would a real police patrol a neighbourhood? Presumably they would go to the "hottest" spots? Or the closest spot that they did not visited for some time? I've tried something with a "dirt map" because criminals do dirty business. Each frame, each spot get "dirtier". Currently in my test the patrol car goes to an intersection that has the most "dirt" ...


4

It looks to me like this could be done with a TrailRenderer. This leaves a ribbon of 3D geometry behind a moving object, onto which we can assign a material to control the way it renders. We can use a custom shader incorporating a GrabPass to take a snapshot of the frame buffer, sampling it with a distortion offset, to get a refractive watery look: Shader "...


3

You get the path the same way you'd move the object when you shoot it. Just have a tight loop that simulates the movement of the object and keep track of the position every so often. Now you have a list of positions, if you draw a dot at each position, you have a dotted line the represents the path of the object if it were to be shot from that angle.


3

They actually do specify it: All values in Sprite Kit are specified using the International System of Units (SI units). Gravity and velocity are both meters per second. (Though gravity ought to be meters per second squared; that might be a typo.) When adding velocity to your sprite, ensure you use the the appropriate method, for instance ApplyForce ...


3

Wrapping the SKEmitterNode in an SKEffectNode allows the EmitterNode to be rendered into a framebuffer which is subsequently rendered onto the screen. I tested this out (after much push and pull of different nodes and scenes and views) and this results in the exact effect you want, where the Add blend mode is applied to a background that is not rendered ...


3

The answer is YES, You may set the gravity vector to (0, -some number) for this purpose, your code which multiplies the g scalar with sin and cos of 45 degree will be true if the Sprite Kit physics coordinate system could be changed to your isometric coordinate system. I mean the direction of the gravity vector is still the Y axis, look at your Z axis (...


3

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 to be fully visible, which would be white. Multiply blend mode will darken all the black areas and the white areas would remain unaffected. Here is a sample ...


3

I'm not really a fan of this : if contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask { firstBody = contact.bodyA secondBody = contact.bodyB } else { firstBody = contact.bodyB secondBody = contact.bodyA } and prefer to do the following: let contactMask = contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask ...


2

(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 country Use containsPoint in the touchesBegan of each country to check if touch is inside (B) If you don't have to use SpriteKit (for this particular part) ...


2

You essentially want to experiment with various noise functions, such as Perlin Noise. The various parameters you choose, and how you interpolate the information, will give you vastly different results. As for how you transform the information into graphics, it'll vary. In Tiny Wings, there's clearly a foreground image that's 'cutout' above the noise ...


2

SpriteKit uses SKAction objects to accomplish most of its functionality. What you're seeking is SKAction's followPath:duration: action. The following accomplishes this: UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:CGPointZero]; [path addQuadCurveToPoint:CGPointMake(deltaX/2, desiredHeight) controlPoint:CGPointMake(0, ...


2

I've implemented the kind of smooth snake movement that you explain. It's actually quite simple, but most of the examples I found while looking were the same kind as you encountered. And I don't think it's as easy to explain in plan words. As you can see, my snake is a bit unusual, thats why providing implementation here is not really optimal. But I think ...


2

You could instead get a random angle (within some range) and then use that for the initial direction of the ball. Something like: // min angle: 10, max angle: 170 int min_angle = 10; int max_angle = 170; int degrees = arc4random_uniform(max_angle - min_angle) + min_angle; float radians = degrees * M_PI/180.0f; myVector = CGVectorMake(cos(radians), sin(...


2

Since I am working with SpriteKit on iOS the shader support in SpriteKit is still missing a few things to implement an animated color gradient shader in SpriteKit. However for those who come up to the same situation I have found a more performant way to make animated gradients with sprite kit. Instead of working with shaders I have created a simple image ...


2

You wil want to subtract the touch with the ref point: //180 is inversed? 180 is when touch is on the right side... let dy = (touch.y - refPoint.y) //opposite let dx = (touch.x - refPoint.x) //adjacent This results in the (dx, dy) vector being from the refPoint to the touch point (as you would expect).


2

You're not taking into account the inverted Y axis in comparison to the normal X axis in most (maybe all?) programming languages. The top left corner of the screen is (0, 0), and is positive in the right and down directions. So if the bottom middle of your screen is, for example, (300, 400), and you click at (0, 400), then your triangle will be a first ...


2

Byte56's answer is very good, especially for the example image given where simulating the movement of each "ball" in the line will work well. I'll give you an alternative idea however which might work better, or might be easier to implement if you are trying to work with a dashed line (with or without animation), something like -- -- -- -- Calculate the ...


2

Typically most of the more feature complete game engines actually have 2 game loops. The first is a fixed step loop aimed at iteration around every 16ms for that ideal 60fps zone. The second is the "as fast as possible" loop. The idea is that some actions like physics processing need to have some idea of process in order to be calculated correctly and ...


2

Particles in SpriteKit are meant for visual effect. They cannot be given physics bodies in the default SK implementation. This would make them very inappropriate for a logical object in your game. Definitely use nodes. Don't worry about performance at this point. It's unlikely to matter, and if it does, you can research ways to improve performance ...


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