Change the Color of CGPOINT - sprite-kit

i have managed to create a SKspritenode , Make it move around , although i want to change the color of every CGPOINT that the node Passes by .
Anyway to do this ?

Use CGShapeNode to draw a path which consists of CGPoints your node passed throught.
For direction on creating a path from points check out answer to this question

Related

How can find Center of circle to Unity?

I have circle, and I'm trying to find center and convert to Vector2.
For example:
circleLocation : new Rect( Screen.width/10, Screen.height/2.75, Screen.width/3,Screen.width/3);
centerofcirle:New Vector2(circleLocation.width/3, circleLocation.height/3);
But this example's not correct, the circle is not turn center. What is this formula? How can find correct center of cirle and how to convert Vector2?
Reading between the lines here, I wonder if issue has nothing to do with your code here, but with the rotation point of your steering wheel object, which isn't where you want it to be.
A common technique to change the rotation point of a game object is to make that object the child of another game object in the Unity Editor. Then set the position of the child object as you wish relative to the position of the parent object. Now, rotate the parent object. The child object will automatically rotate around the parent object's position, since it's transform (including position/rotation) is relative to it's parent's.
You seem to be defining your circle using a Rect so just use the Rect.center property:
circleLocation.center;

How to stretch a node to a CGPoint

Hello dear developers...
One of my function gets a starting point and an ending point. Both are 'CGPoint's. I want to create a a sprite node at the starting point and then, I want to stretch that node to the ending point. How can I do that? Attention I don't want to change it's position, I want to resize it until X-Axis touches the ending point. Thanks in advance...

SpriteKit Select Sprite node from CGPoint

First post,
I'm in Apple's SpriteKit framework...(new programmer) and I have a bunch of nodes that are stationary. How do I select/grab a particular node if I know the coordinates (CGPoints)? I basically want to say, grab that node at (x,y) and do something with it (i.e. change color)
Thanks
If you know the CGPoint, you use the command nodeAtPoint: However, this command only returns the deepest descendant that intersects a point. If you have the possibility of having more than one node at your CGPoint, you should use the command nodesAtPoint: instead.
Read up on the details in the SKNode Class Reference - section titled Determining If a Point Lies in a Node.
** Update **
CGPoint myPoint = CGPointMake(10, 10);
SKNode *myNode = [self nodeAtPoint:myPoint];
Where self either is or needs to be replaced with the parent node of the node you are looking for.

iPhone: How to animate a CAShape line whose path is determined by user input

I'm attempting to replicate the "worm" that is sometimes displayed on political debates to represent the audiences opinion on how well a candidate answered a question. It's basically a line that animates along the x axis to represent time, up and down the y axis to represent opinion.
I see that I can do this animation by
Creating a UIBezierPath and use its moveToPoint/addLineToPoint methods with a predefined set of coordinates.
Create a CAShapeLayer and set its path property to the above UIBezierPath.
Create a CABasicAnimation and add it to the CAShapeLayer.
This is all fine but I need for the line to be affected in real time by user input (tapping a button to move the line up or down), meaning that in step one above I cannot have a set of pre-defined coordinates. The line should move horizontally unless it receives input from the user to make it also move vertically.
So my question is how would I go about this? Can I still somehow use the method I described in the bullet points above with some modification or do I have to use a different means?
Many thanks for any advice!
[edit]
I just had a thought, this may work but be a little inefficient and I'm not sure if the created path would be very short i.e. not the full path from the starting point instead just the currently drawn part of the path?! What if I did the following:
create two variables, lastPoint and currentPoint;
repetitively call a draw method that does the following
[path moveToPoint: lastPoint];
[path addLineToPoint: currentPoint];
lastPoint = currentPoint;
currentPoint = [self calculateNewPointFromUserInput];
repeat;
Two points will be very short for you, you can take an array of user's touch events and then draw last 10-15 points from the array. I think this will serve your purpose.

How can I determine if the current position is within a KML-defined area?

I have some KML data which defines an area on a map, such as the following:
131.0764742247829,-15.80786022929951,0 132.6357700620065,-16.54895727734661,0
134.1119108999971,-17.28040233069844,0 135.8545033459996,-18.1298170074137,0
137.7396886168202,-19.07860187595016,0 140.011948401144,-20.18462043802856,0
142.3114600417346,-21.19369381963822,0 144.1566045495202,-22.15731684591415,0
I'd like to determine within my iOS application if the user's current location is inside of this defined area. How can I do this?
If you know the center and radius of the circle then it is quite easy.
CLRegion *circle = [CLRegion initCircularRegionWithCenter:centerCoordinate radius:circleRadius identifier:#"myCircle"];
BOOL doesItContainMyPoint = [circle containsCoordinate:myLocation];
Update based on revised question
I've never tried this, but couldn't you create a UIBezierPath with your points (you don't have to actually draw the bezier path) and then use UIBezierPath's - (BOOL)containsPoint:(CGPoint)point to test for inclusion?