Move an imageView along a circular path - iphone

I'm developing a game in which I've imageviews for bow and arrow. I actually wanted to move this arrow along a circular path when set in the air. Specifically, this circular path should be the one which an object will travel when thrown in the air at a distance i.e. it'll move upwards first and then downwards.
I've already tried using CAKeyFrameAnimation but the curved path drawn was actually down first and then up, objects don't usually travel that way.
I have already seen other articles related to this on Stack Overflow and nothing seemed suiting my requirements. I hope I didn't miss anything.

I've already tried using CAKeyFrameAnimation but the curved path drawn was actually down first and then up, objects dont usually travel that way
Sounds like all you need to do is change your math for the y axis. Do your current math but multiply the y axis delta by -1.

Related

Using shader graphs to add an outline to a sprite of a tank. Despite following tutorials, the outline distorts the sprite

I'm trying to add a black outline surrounding a sprite I have for a tank.
I've tried following every tutorial I could find on 2d outlines for sprites, however almost all of them were done using a previous unity version (I'm using 2021.1.3f1) and don't seem to have any of the problems I've been having.
After using Alpha subtraction on an offset copy of the sample texture (and multiplying by a color) I then try to add it back to the original sample texture. That's when things go wrong, no matter what I've tried it keeps either chopping off the right side of the sprite (I was trying to add the left outline first), or making the right side of the sprite the opposite color of what I'm putting on the left.
What I mean by "cutting off the right", those treads should be the same thickness on the right as on the left, it's like adding the outline to one side trimmed the other.
If it matters, the sprite is a PNG I got from Kenney and then modified in Krita.
For whatever reason, changing the color of the outline seems to also change how much is getting trimmed.
I've been banging my head against this for four hours now, any ideas or suggestions are greatly appreciated.
Update: After following One Full Time Equivalent's suggestion below I do get an outline surrounding the entire sprite, but now it's distorting the colors at the edges of the sprite as seen here:
After replacing Add with Blend
After your subtraction node, put in an Absolute node, otherwise you will subtract the right edge in the alpha channel (this is exactly what you observe right now). Always be aware that you can only see half the color space and negative channels can be tricky to deal with.

Does Leaflet have a "geopositioning mode"?

I use the Leaflet plug-in "Leaflet.ImageOverlay.Rotated.js" to use its L.imageOverlay.rotated(...) thing in order to overlay certain map pieces in various places on top of the normal map.
It does this by taking an image and having me tell it its top-left, top-right and bottom-left coordinates to figure out how to rotate, tilt and stretch/squeeze it properly.
It took me a very long time to figure these coordinates out by hand. For this reason, I'm looking for some sort of "geopositioning mode", perhaps enabled by this extension, which would simply let me click three times on the map to tell it where these points go. That would be so simple for the developers to do and would help so much. It's such an obvious thing to do that I strongly suspect it's already implemented and ready.
Is there such a "mode"? If not, how am I expected to find the positions without spending so much time and trial-and-error as I did for the first overlay map image?
Added: I should also clarify that the image should be shown in this mode so that you can re-adjust the points and watch in real time as the image bends/warps, to get it just right.
you can develop a modul for this problem.
find minimum 4 point on raster map.
click on tilemap for 4 points
than find different slope and distance same 2 points.
maybe you must rotate and use affine transformation.

At some position character cannot see the whole mesh in unity

I want to show a transparent building in our project. I did that by setting the material of the mesh to be "transparent/diffuse". However, there exists some visibility problem of the mesh of the building. At some position, I can only see two or three sides of the cuboid(the transparent block, i.e the building). If I adjust my character position, I can see the whole cuboid. I googled the similar question online, someone mentioned about the frustum view of the camera. It seems like character has to be inside the frustum view of the camera, then user can see the whole mesh of the cuboid.
Can anyone give me some suggestions? I feel like it might be something about the way of how I build my mesh for the building, but at some position, I can see the whole cuboid.
I've solved this problem. It is just about the way how you construct the mesh.Basically, for the cuboid, I reconstructed the mesh in this way:
triangles[0]=topleft;
triangles[1]=topright;
triangles[2]=bottomright;
triangles[3]=bottomright;
triangles[4]=bottomleft;
triangles[5]=topleft;
Note: This is just front side, the other sides should be constructed in a same way.
Besides, in order to show the mesh when user enters the block, you have to construct the inside area of the block in previous way.

Objective C Drawing free form shape on top of image

I am working on a iOS 5 iPhone project where users can choose an image on their device, then trace an object inside of the picture (trace an apple out of a picture of a fruit basket), and then the picture needs to be uploaded with the "tagged" object so it can be pulled down later. Other people will then pull down the image and try to find where the tagged object is in the picture (Think "Where's Waldo?").
I have been trying to figure out the best way of tracing the object. Before, I had a user press the top left, top right, bottom left, and bottom right points around the object and create a square view around the object. The info for that view was uploaded and then pulled down for the user to find the object. The downside is that all objects are obviously not squares/rectangles so I need to do a free form shape.
I was thinking of allowing the user to draw over the object and then somehow I need to be able to tell what is inside of the trace (For example, inside of a circle that they traced), but a problem I forsee is making sure the trace they made is closed so I can fill in the shape (which is a whole not problem).
Any advice welcome on the best way of starting this.
Thanks!
UIBezierPath might be a very useful friend here. It allows you to create any shape you need, and it supports both drawing and hit-detection. I recently did an implementation for a storybook where I could trace out a shape with their finger, freeze it, and then use the shape for tap detection.
The basic idea is this:
When your finger touches the screen, start recording positions. Discard any positions that are too close to the previous position (eg, only record a point if it is >min-distance from the last recorded point). While doing this, you can draw the UIBezierPath so you can see what you are tracing out. Modify the UIBezierPath by adding points to it, instead of recreating it every time.* When you lift your finger, close the bezier path. Quite simple.
Now, this will result in a polygon (ie, straight edges). If your min-distance is low enough or if you are using it for hit-detection (as you say), it won't really matter. However, if you want to smooth the path, you have to use the curve-to methods, which slightly complicate it - but should you wish to follow up on this more, read up on splines and spline generation from a point series.
*note: otherwise you'll get lag while drawing large shapes because recreating a bezier path from an increasingly large series of points gets expensive. Modifying the existing path makes it much, much, much faster.

Infinite maps/scrolling question

I'm using cocos2d for the iPhone to create an infinitely scrolling horizontal tile map. To achieve this, I've generated a library of 'segments', which are basically horizontal chunks of levels that I randomly choose from and append to the end of that particular levels tile map. When tiles scroll off of the left of the screen they are removed from the layer and released. This all works fine.
My question revolves around the legitimacy of the scrolling method I've chosen. Following guidance from this article, I've been scrolling my map by updating the layers position at regular intervals (subtracting from the x axis to move the layer to the left). And while this works, I'm concerned that there's probably some finite limit to the positioning of a layer. Am I going to run into issues after a certain amount of time has passed (when the layers x-axis position is considerably large?)
Any thoughts on my approach would be appreciated.
This is a good question. What I would do is run some tests on how far you can position the layer. I placed a sprite and focused the camera to ccp(1000000000000000, 1000000000000000) with no issues.
Do you really think this would be an issue in real gameplay? Seems like it would take a very long game to reach a position like that.