Questions tagged [cgpoint]

CGPoint is a structure from Apple's Core Graphics framework. It is used to represent a point in two dimensions.

CGPoint is a C struct that contains information about the location of a point in two dimensions.

Fields:

  • x: The X location of the point
  • y: The Y location of the point
509 questions
2
votes
2 answers

Memory management about CGPoint

refer to CGPointMake explaination needed? Correct me if I am wrong, in the implementation of CGPointMake, CGPoint p; declare a local variable of a struct, which should should be freed after leaving the scope. But why the function can return the…
Kay Chan
  • 345
  • 1
  • 3
  • 11
2
votes
1 answer

Getting a Sprite to 'follow' another Sprite in SpriteKit

I'm trying my best to make a simple "tower-defense" game on my own (both to learn SpriteKit and get my feet wet in game development in general). I've got most of the game working, but my trouble is when it comes to the tower "shooting" at the…
Su_toL
  • 167
  • 2
  • 15
2
votes
2 answers

Invalid initializer, CGPoint

i have this code and on the second line it gives me an error that says invalid initialzer this is the code: -(void)setPlayerPosition:(CGPoint)position { CGPoint tileCoord = [self tileCoordForPosition:position]; int tileGid = [_meta…
retsrif
  • 35
  • 1
  • 6
2
votes
1 answer

Convert a CGPointo to Int in swift

I'm building a class to handle with a basic graphic. I'm a newby and I'm on a self learning project to build small apps in Swift for IOS devices, since I found the language very easy to learn. I've set in my class of type UIView two constants of…
2
votes
1 answer

How to find closest station point from UITouch on iOS

I am trying to make iOS subway map application. I have a subway map imageview looking something like this: When the user touches somewhere close (so that the user doesn't neccessarily have to touch on the exact location) to the station, I want to…
Joon. P
  • 2,238
  • 7
  • 26
  • 53
2
votes
1 answer

Getting touch coordinates in Swift 1.2

I'm trying to get the coordinates of a touch on the screen, but every time it just gives me 0, 0. I could only find basic help with this function in the new version of Swift, and nothing on this problem. What am I doing wrong here? override func…
noizybrain
  • 155
  • 1
  • 15
2
votes
1 answer

Swift CGPoint in relation to another CGPoint

I am trying to have two UIButtons. One is 8 points from the edge of the UIView they are inside and the second one is 4 points from the start of the first. I am currently doing this let buttonFrames: CGSize = CGSizeMake(56, 42) let…
Cody Weaver
  • 4,756
  • 11
  • 33
  • 51
2
votes
1 answer

Swift: Sort NSArray of CGPoints by one value, then another?

I'm trying to sort an NSArray of CGPoints (describing a CGPath) by their y values (descending), then by their x values (ascending). This is what I have so far (Swift code): var anglePoints:[CGPoint] = [CGPoint(x: 0, y: 0), CGPoint(x: 32, y: 32),…
MassivePenguin
  • 3,701
  • 4
  • 24
  • 46
2
votes
1 answer

POPSpringAnimation toValue CGPoint bug with Swift

I have an strange bug with CGPoints using POP Animation Framework and Swift I've always used Objective-C and Pop to make animations but now I'm trying to do the same with Swift and when I try to run the next code it dies with the following error:…
lojals
  • 981
  • 10
  • 19
2
votes
0 answers

Xcode Check If Point Is in Transformed UIView

I have a UIView with a height of 100 and a width of 50. I am then rotating the view 45 degrees. After I rotate the view, then frame increase. How Can I determine If a point lies inside the view. If I just compare the frame to the point I will get a…
Alex Pelletier
  • 4,933
  • 6
  • 34
  • 58
2
votes
1 answer

CGPoint stringliteral not allowed anymore in iOS 8.1

In iOS 8.0 I had this enum: enum Direction:CGPoint { case Top = "{0, -1}" case Right = "{1, 0}" case Down = "{0, 1}" case Left = "{-1, 0}" case TopLeft = "{-1, -1}" case TopRight = "{1, -1}" case DownLeft = "{-1, 1}" …
Arbitur
  • 38,684
  • 22
  • 91
  • 128
2
votes
1 answer

How to animate a drawn line in Objective C?

I am trying to animate drawn objects, for example I have drawn a line with this approach: UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:CGPointMake(Center.x, Center.y)]; [path…
Shamy
  • 723
  • 1
  • 8
  • 13
2
votes
2 answers

CGPoint x on SKSpriteNode not working correctly(Half of Node out of screen)

I'm actually developing a game in Swift SpriteKit. I set the position of a SKSpriteNode: skPart1.position = CGPointMake(0, 100) So the node should start at the very left window-edge. |-------------------------| …
Christian
  • 22,585
  • 9
  • 80
  • 106
2
votes
0 answers

How to get coordinates of the tap in 2 views simultaneously

I am working on an iOS map app and it includes interactive map. The interactive map is a subclass of UIImageView and placed on a scrollView. My view hierarchy is shown below: When user taps some part of the map, ViewController performs animated…
Richard Topchii
  • 7,075
  • 8
  • 48
  • 115
2
votes
4 answers

Create random CGPoint with Swift

So, I'm trying to develop a simple game written in Swift, but I'm having trouble doing a pretty simple thing. I can't manage to create a random CGPoint... When using arc4random, a compiler error shows up telling me that I can't use Int32 in a…
José María
  • 2,835
  • 5
  • 27
  • 42