Frage

I'm using "Sprite Kit", and I have a node displayed at a certain point. It looks great on the "4 inch screen", but it's off on the "3.5 inch screen" and REALLY off on the iPad's iPhone simulator. I set the location like this:

    myNode.position = CGPointMake(self.size.width/2, self.size.height - self.size.height/10);

So, I would think it should display properly regardless of size, but it's not. I'm sure I'm just doing something wrong, and I think (and hope) there should be a simple solution.

War es hilfreich?

Lösung

If you want to display it to top left corner,

myNode.position = CGPoint(x: myNode.size.width * 0.5,
                          y: self.size.height - myNode.size.height * 0.5)

To middle left,

myNode.position = CGPoint(x: myNode.size.width * 0.5, 
                          y: (self.size.height - myNode.size.height) * 0.5);

To bottom left corner,

myNode.position = CGPoint(x: myNode.size.width * 0.5,
                          y: myNode.size.height * 0.5);

To middle bottom,

 myNode.position  = CGPoint(x: (self.size.width - myNode.size.width) * 0.5,
                            y: myNode.size.height * 0.5);

To right bottom corner,

 myNode.position  = CGPoint(x: (self.size.width - myNode.size.width) * 0.5,
                            y: myNode.size.height * 0.5);

To middle right,

myNode.position  = CGPoint(x: self.size.width - myNode.size.width * 0.5,
                           y: (self.size.height - myNode.size.height) * 0.5);

To top right,

myNode.position  = CGPoint(x: self.size.width  - myNode.size.width * 0.5,
                           y: self.size.height - myNode.size.height * 0.5);

To middle screen,

myNode.position = CGPoint(x: (self.size.width - myNode.size.width) * 0.5,
                          y: (self.size.height - myNode.size.height) * 0.5);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top