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
1
vote
3 answers

Finding CGPoint by adding into distance of two CGPoints

I have two CGPoints A and B. Distance between A and B can be found with ccpDistance(A,B). With this information, I need to find programmatically CGPoint(x,y) of X by adding small distance into distance of A-B. A-B may can make a connecting line in…
WaJiyaz
  • 512
  • 1
  • 8
  • 25
1
vote
1 answer

Hit Test rotated view

I need to write a function that will return true if given point is inside any of subviews hierarchy of view A. A can be transformed (rotated), and has clipToBounds disabled. It's subviews also can have clipToBounds disabled, and true must returned…
Damian Dudycz
  • 2,622
  • 19
  • 38
1
vote
1 answer

why is self.frame.maxY not showing on the screen for iPad

I am building a game with swift and sprite kit and I want to place a sprite on the very top of the screen. when I do sprite.position = CGPoint(x: 0 , y: self.frame.maxY) on an iPhone it places the sprite on the top, however on an iPad it does not …
Arjun
  • 358
  • 5
  • 14
1
vote
0 answers

Should coordinates be stored in CGPoint or CLLocation?

These both seem like common options that are used to store an array of coordinates. If I were to store 1000 coordinates in an array, would it be better to use an array of CGPoint or CLLocation? CLLocation seems to store extra information like…
user3614030
  • 481
  • 6
  • 16
1
vote
1 answer

iOS: Remove last image in array after touchesEnded has been completed

I am building an iOS drawing application and I am trying to implement a undo button to remove the line drawn by the user. I've created an array of images in a variable: var images = [UIImage]() Each time the user swipes and removes the finger from…
Tessa
  • 403
  • 1
  • 5
  • 13
1
vote
1 answer

Hit Test to determine which CGPoint was closest to touch - 16 CGPoint dots in 1 UIView

I've been modifying this custom UIView by LMinh called LMGaugeView in order to make it look like a 16-vial circular "vial carousel". Imagine 16 dots (CGPoints) evenly dispersed around the edge of the circle (UIView). I want to be able to do the…
Anthony_b
  • 23
  • 6
1
vote
0 answers

How can I have one object follow another in Swift?

I am writing a game in Swift. I have a player which can move around the screen. I want the SpeedLines (which are an animation) move with the player (directly above it). Also, when I compile and run my project, sometimes the SpeedLines don't show up…
Aidan
  • 89
  • 1
  • 2
  • 11
1
vote
1 answer

AffineTransform a CGPoint

I've been doing research all morning. No luck so far. I'm trying to rotate a CGPoint around the center of my view. Here's what I do for UIBezierPath: CGRect bounds = self.bounds; // might want to use CGPathGetPathBoundingBox CGPoint center =…
digit
  • 197
  • 9
1
vote
3 answers

Which way is better to move an ImageView

I would like to move an ImageView around the screen many times, until now I have found two ways. However I am not sure which one is more efficient, or maybe both are the same. Please, could I have some advice ? Thanks. // Create ImageView and add…
TxabiGG
  • 15
  • 2
1
vote
2 answers

CGPoint: Cannot call value of non-function type `[Float]`

I am developing an app, which should draw points when is touch, in the location of touch and when I have got 2 or more points, it should connect these points and fill up the new object. override func touchesBegan(_ touches: Set, with…
Josef
  • 33
  • 9
1
vote
1 answer

copy uiimageview origin to CGPoint

I am new to iPhone/Objective-C programming. I have a UIImageView *myImage whose x,y,width,height are set using CGRect with values (20,20,100,100) or whatever; Q1) When I do the following why can't i fetch the origin values into CGPoint. CGPoint…
Prazi
  • 335
  • 1
  • 5
  • 18
1
vote
1 answer

Moving Background Swift SKSpriteKit

I'm currently working on an application where I'm trying to set up a moving background. I have a transparent image full of clouds that I'm currently using. My problem is, how can I make it move more smoother? I've tried to play with the speeds but…
Dewan
  • 429
  • 3
  • 16
1
vote
1 answer

Moving a point along a vector

I have a point defined by x,y and a vector defined by heading, speed. I am attempting to move the point x,y along this vector, at a distance of 'speed'. Below is the code I am currently using: self.x += self.speed * cos(self.heading); self.y +=…
Chris
  • 1,037
  • 15
  • 26
1
vote
1 answer

Negative 0 in CGPoint's x or y value

When multiplying a zero x or y value of a CGPoint variable with -1, the resulting value is -0. Is this intended behavior? I think that's odd, it took me quite some time to find that out. I use Swift 3.1 in Xcode 8.3.2.
1
vote
1 answer

Using core data to save CGPoint

I am using core data to save the text that is added to the labels, each of these labels is on view that can be moved. I am currently saving the text with an entity that is a string, which works fine. How would I use core data to save the CGPoint of…
knowles3226
  • 65
  • 1
  • 7