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

What exactly am I accessing in my code?

Forgive my ignorance but I have a hard time remembering what I'm accessing in my code. if (pos.x < leftBorderLimit) { pos.x = leftBorderLimit; playerVelocity = CGPointZero; } else if (pos.x > rightBorderLimit) { pos.x =…
Space Ghost
  • 765
  • 2
  • 13
  • 26
-2
votes
1 answer

What libraries do we need to include to use CGPoint and arc4random()?

It's my first program in Swift. The function returns two random locations (CGPoints) which are points on the perimeter of a circle of radius = variable (passed in by the calling program). The two CGPoints must also be greater than degreesApart…
Abdul Ahad Akram
  • 455
  • 3
  • 12
-2
votes
2 answers

Binary operator ‘+=’ cannot be applied to two ‘CGPoint’ operands

Basic Syntax Problem but, I can't solve it func updateForeground(){ worldNode.enumerateChildNodes(withName: "foreground", using: { node, stop in if let foreground = node as? SKSpriteNode{ let moveAmount = CGPoint(x:…
user10748408
-2
votes
2 answers

Adding layout constraints to a button

Refreshing my self with Swift ... I want to center this button loginButton.center = self.view.center at the bottom of the view. The current code centers the button perfectly horizontally and vertically.. I have tried messing around with CGPoints…
-2
votes
1 answer

CGPoint is unavailable for Swift

this question could be a possibile duplicate. I've deleted and re asking the same question only to provide an answer that could help others to fix this issue collision.addBoundary(withIdentifier: "barriera" as NSCopying, from: CGPoint(0,…
Riccardo
  • 66
  • 2
  • 16
-2
votes
1 answer

Drawing from dictionary pixel by pixel from one image to another with same coordinates

I'm trying to copy from image 1 to image 2 pixel by pixel, and I save the data from the image 1 in dictionary: [UIColor:CGPoint]. How to draw on CGContext all points pixel by pixel with the exact color for certain pixel on the image 2 at the same…
Bogdan Bogdanov
  • 882
  • 11
  • 36
  • 79
-2
votes
2 answers

convert NSMutableArray to CGPoint Array

the typical answer will be "you can convert it to nsvalue and then use [element CGPointValue]; but in my case i need to generate array of type CGPoint , as i need it in a built in function below : static CGPathRef createClosedPathWithPoints(const…
Mostafa Sultan
  • 2,268
  • 2
  • 20
  • 36
-2
votes
4 answers

If statement: CGPoint returns strange value

I have an variable with the datatype CGPoint, named endPosition. When endPosition gets its value inside an if statement, it returns this crazy value: End position: {1.6347776e-33, 1.4012985e-45}. 1. example: if ([touch view] != background) …
thar
  • 1,094
  • 2
  • 13
  • 25
-2
votes
1 answer

How to go particular point location inside UIWebView

I have UIWebView and have x & y coordinates. When i go to viewcontroller i need to go that particular coordinate inside UIWebView. But it loads the view from zero position. It's like a bookmark on page. When i bookmark i'm getting coordinates value…
user2967559
  • 97
  • 2
  • 13
-2
votes
1 answer

I need to check the X & Y points of a CGPoint for an image, then show an alert

I'm making a game where images fall from the top of the screen, and I need to detect when they reach/go past a certain x & y value. I tried doing: if (asteroid.center.y == 296 && asteroid.center.x == 50) { // etc...displayed alert } But for…
Ryan Cohen
  • 13
  • 6
-3
votes
2 answers

Create Array of CGPoints in Swift

I have code that loops through an array of doubles and creates a CGPoint from the double and the index of the array. However, I can't figure out how to place the resulting CGPoints into an array. Here is my code: var points = [CGPoint].self//The…
user6631314
  • 1,751
  • 1
  • 13
  • 44
-3
votes
2 answers

How to convert CGPoint to Int?

I've set a CGPoint constant in my class of type UIViewController: let point = gesture.location(in: gesture.view) This point constant is CGPoint, but I need it to be Int. Is there a way to convert CGPoint to Int?
Isha Balla
  • 733
  • 2
  • 9
  • 25
-5
votes
1 answer

Cannot convert value of type int to specified value CGPoint

I have some code that is supposed to swipe a sprite in any direction taking in an initial value of a CGPoint. I tried setting up a variable for this as var initialLocation:CGPoint = 0 I know this is not how you're supposed to do it but I forgot…
-6
votes
1 answer

Stop an Increment

I have the Y axis increasing very few frames with the following line: Bullets.center = CGPointMake(Airplane.center.x, Airplane.center.y + Y); How can I stop increasing Y when an if statement is true?
TheEliteTech
  • 147
  • 3
  • 11
1 2 3
33
34