Create linear motion with Swift in iOS [closed] - ios

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
What I'm trying to do seems very simple, yet I'm struggling to make it work. I'm creating a simple SpriteKit game, similar to FlappyBird. The main character stays vertically stationary while the user controls its horizontal motion. That part is no problem. At the same time, other game elements should be moving vertically at a constant speed. I need to detect contact, but do not need to react with physics to the contact (the moving elements either disappear on contact, or the contact causes game to end).
I've tried using physicsBody.velocity, but the results are erratic. Conceptually, this is my desired approach because I want to control the velocity, speeding or slowing as the game progresses.
I've also tried using Actions, and this works ok but it's challenging to create constant motion, and it's difficult to imagine how to speed and slow the motion with Actions. My best results are with SKAction.sequence, but have difficulty coordinating multiple elements to move in sync.
Any clues would be most appreciated.

You can create the host node – world: SKNode to control all the moving objects – just add them as childs. And use that node to rule the world – set world.speed = 0.0 to stop all SKActions, world.speed = 2.0 to move them twice as faster

Related

Changing the gravity pull on specific nodes with SpriteKit [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I'm trying to make a game where nodes fall from the top of the screen to the bottom, which I've done by using gravity. Now I want to move some nodes from the left side to the right.
I was wondering if I could change the gravity pull on different nodes instead of them falling down the screen the gravity could pull selected nodes left to right.
I know I can do this by using a NSTimer and a function but wondering if I could do this with gravity.
I have tried googling the answer but I can't find the answer to applying two gravity pulls.
I don't think you can have 2 distinct gravity forces into the same physics world.
However if you want some node to "fall" to right you could
Apply another acceleration (same as gravity but opposite direction) to that specific body (this will cancel the gravity pull)
Apply one more acceleration versus right to the specific node.

Recognising complex objects in an image [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm going to be more specific about the situation:
I've captured a screenshot from the game DotA. The information I want to get is what objects eg. heroes (also its name, hp, ...), creeps (also which side), towers, etc. is visible in the image and where they are. A problem come from the fact that in DotA 2 many of these object can be viewed from many perspective, so let's reduce the problem and assume that every object have only one orientation. How might this problem be solved quickly enough, that it can recognise all objects in real time at about 30fps? Any help or suggestions is welcome.
I think that you have the good flags: CNN for image segmentation. So my point is that for so many different objects from different points of view and scale (because I guess that you can zoom in/out on your heroes/objects), the easiest way (but the heaviest in term of computation) is to build one CNN for each type of object.
But images would help a lot to get a better understanding of the problem.

Need some tips which localization method to use for my NAO robot (robotic) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
for university I'm working on a project in which I have to teach a robot(Nao-robot) play nine men's morris. Unfortunately I'm fairly new to the area of robotics and I need some tips how to solve some problems. Currently I'm working on the localization/orientation of the robot and I'm wondering which approach of localization would fit best in my project.
A short explanation of the project:
The robot has a fixed starting position and has to walk around on a boardwhich has a size of about 3x3 meter ( I will post a picture of the board when i reach 10 reputation). There are no obstacles on the field except the game tokens and the game lines are marked yellow on the board. For orientation I use the two camera devices the robot has.
I found some approaches like
Monte Carlo Localization
SLAM (Simultaneous Localization and Mapping)
but these approaches seem to be quite complex for a beginner like me and I would really appreciate if some has some good ideas what would be a simpler way to solve this problem. Functionality has for me a far higher priority than performance.
I have vague knowledge about the nine men's morris game as such, but I will try to give you my simpler idea.
First thing first, you need to have a map of your board. This should be easy in your case, cause your environment is static. There are few technique to do this mapping from your board. For your case I would suggest to have a metric map, which is an occupancy grid. Assign coordinates to each cell in the grid. This will be helpful in robot navigation.
As you have mentioned, your robot starts from a fixed position. On start up, initialize your robot with this reference location and orientation (with respect to X-Y axes of the grid, may be you don't need the cameras, I am not sure!!). By initialization I mean, mark your position on the grid.
Use Dead Reckoning for localization and keep updating position and orientation of your robot as it move through the board. I would hope that your robot get some feedback from the servos, like number of rotations and so forth. Do that math and update the position coordinates of your robot as it move into different cell in the grid.
You can use A-Star algorithm to find a path for your robot. You need to do the path planning before you want to navigate. You also have to mark those game tokens on the grid, to avoid collisions in planning the path.

Kite depth in sprite kit game [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to create a game kite flying . Now suppose we have two button's Up and down. When we press on button up kite go away from screen and it should look realistic small while its going away and away on continues press . If we press on down it should come down in same way and it look bigger .
How can show kite depth on screen with sprite kit or any other framework ?
Thanks
Rajender
You could try adjusting the Scale property of the SKNode when a user presses the up button. You'll have to detect the specific key type that you're looking for, but you could do something like:
- (void)handlePressDown:(UIGestureRecognizer)recognizer
{
// ....Detect specific keystroke
_kiteScaleAmount++;
[kite setScale:_kiteScaleAmount];
}
More info on SKNode here.
Since you included the [scenekit] tag in your question, perhaps you're also looking for 3D solutions?
You can use SK3DNode to add 3D content—an embedded SceneKit scene—to your otherwise 2D SpriteKit game. So, if you have a 3D model of a kite, you can build a SceneKit scene around that, then attach it to an SK3DNode in your game. Then, to make the kite get farther and nearer to the viewer, adjust the camera in the SceneKit scene.

iOS Cocos2D optimization [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I´m building a game that reads a bidimensional array so that it creates the map, but the walls are all separated from the corners and floors, each wall, each corner and each floor is an individual image, and this is consuming a lot of CPU, but I really want to create a random feeling of the map, and that´s why I´m using an image for each corner and wall.
I was thinking that maybe I could generate a texture built by merging 2 or more different textures, to enhance performance.
Does anyone know how that I could do that? Or maybe another solution? Does converting the images to PVR would make any difference?
Thanks
For starters, you should use a texture atlas, created with a tool like TexturePacker, grouping as much of your 'images' onto a single atlas. Basically load it once and create as many sprites from it as you want without having to reload. Using PVR will speed up the load, and benefit your bundle size.
Secondly, especially for the map background, you should use a CCSpriteBatchNode that you init with the above sprite sheet. Then, when you create a tile, just create the sprite and add it to the batch node. Add the batch node to your scene. The benefit of this is that regardless of the number of sprites (tiles) contained in the batch node, this will all be drawn in a single GL call. Now, that is where you will gain the most benefit from a performance standpoint.
Finally, dont rely on the FPS information when running with the simulator. The simulator does not make use of the host's GPU, and its performance is well (much) below what you get on a device. So before posting a question about performance, make certain you measure on a device.

Resources