I'm trying in various ways and I'm not getting success, I have managed in a way that will not be viable, does anyone know how I could do more or less in this idea to get the center position of the circle and calculate points (x, y) outside the radius.
func pressedAddBubble(sender : UIButton!){
let direction = self.mainBubble!.getDirection()
let width = CGFloat(self.mainBubble!.getWidth() * 0.8)
let height = CGFloat(self.mainBubble!.getHeight() * 0.8)
if direction == 0 {
//print("leste")
//adiciona as bolha ao Leste da bolha principal
let x = CGFloat(self.mainBubble!.MainBubble.frame.minX + self.mainBubble!.getWidth() + self.mainBubble!.getWidth() * 0.1)
let y = CGFloat(self.mainBubble!.MainBubble.frame.minY + self.mainBubble!.getHeight() * 0.1)
let bubble_aux = Bubble(v: self.view,
src: randomMoldura(),
image: imageTeste,
x: x,
y: y,
w: width,
h: height)
bubbles.append(bubble_aux)
self.mainBubble!.setDirection()
} else if direction == 1 {
//print("nordeste")
//adiciona a 1 bolha ao Nordeste da bolha pricipal
let x = CGFloat(self.mainBubble!.MainBubble.frame.maxX + self.mainBubble!.getWidth() * 0.1)
let y = CGFloat(self.mainBubble!.MainBubble.frame.minY - self.mainBubble!.getHeight() + self.mainBubble!.getHeight() * 0.1)
let bubble_aux = Bubble(v: self.view,
src: randomMoldura(),
image: imageTeste,
x: x,
y: y,
w: width,
h: height)
bubbles.append(bubble_aux)
self.mainBubble!.setDirection()
} else if direction == 2 {
//print("norte")
//adiciona as bolhas ao Norte da bolha principal
let x = CGFloat(self.mainBubble!.MainBubble.frame.minX + self.mainBubble!.getWidth() * 0.1)
let y = CGFloat(self.mainBubble!.MainBubble.frame.minY - self.mainBubble!.getHeight() + self.mainBubble!.getHeight() * 0.1)
let bubble_aux = Bubble(v: self.view,
src: randomMoldura(),
image: imageTeste,
x: x,
y: y,
w: width,
h: height)
bubbles.append(bubble_aux)
self.mainBubble!.setDirection()
} else if direction == 3 {
//print("noroeste")
//adiciona as bolhas ao Noroeste da bolha principal
let x = CGFloat(self.mainBubble!.MainBubble.frame.minX - self.mainBubble!.getWidth() + (self.mainBubble!.getWidth()) * 0.1)
let y = CGFloat(self.mainBubble!.MainBubble.frame.minY - self.mainBubble!.getHeight() + self.mainBubble!.getHeight() * 0.1)
let bubble_aux = Bubble(v: self.view,
src: randomMoldura(),
image: imageTeste,
x: x,
y: y,
w: width,
h: height)
bubbles.append(bubble_aux)
self.mainBubble!.setDirection()
} else if direction == 4 {
//print("oeste")
//adiciona as bolhas ao Oeste da bolha principal
let x = CGFloat(self.mainBubble!.MainBubble.frame.minX - self.mainBubble!.getWidth() + self.mainBubble!.getWidth() * 0.1)
let y = CGFloat(self.mainBubble!.MainBubble.frame.minY + self.mainBubble!.getHeight() * 0.1)
let bubble_aux = Bubble(v: self.view,
src: randomMoldura(),
image: imageTeste,
x: x,
y: y,
w: width,
h: height)
bubbles.append(bubble_aux)
self.mainBubble!.setDirection()
} else if direction == 5 {
//print("sudoeste")
//adiciona as bolhas ao Sudoeste da bolha principal
let x = CGFloat(self.mainBubble!.MainBubble.frame.minX - self.mainBubble!.getWidth() + (self.mainBubble!.getWidth()) * 0.1)
let y = CGFloat(self.mainBubble!.MainBubble.frame.maxY + self.mainBubble!.getHeight() * 0.1)
let bubble_aux = Bubble(v: self.view,
src: randomMoldura(),
image: imageTeste,
x: x,
y: y,
w: width,
h: height)
bubbles.append(bubble_aux)
self.mainBubble!.setDirection()
} else if direction == 6 {
//print("sul")
//adiciona as bolhas ao Sul da bolha principal
let x = CGFloat(self.mainBubble!.MainBubble.frame.minX + (self.mainBubble!.getWidth()) * 0.1)
let y = CGFloat(self.mainBubble!.MainBubble.frame.maxY + self.mainBubble!.getHeight() * 0.1)
let bubble_aux = Bubble(v: self.view,
src: randomMoldura(),
image: imageTeste,
x: x,
y: y,
w: width,
h: height)
bubbles.append(bubble_aux)
self.mainBubble!.setDirection()
} else if direction == 7 {
//print("sudeste")
//adiciona as bolhas ao Sudeste da bolha principal
let x = CGFloat(self.mainBubble!.MainBubble.frame.maxX + self.mainBubble!.getWidth() * 0.1)
let y = CGFloat(self.mainBubble!.MainBubble.frame.maxY + self.mainBubble!.getHeight() * 0.1)
let bubble_aux = Bubble(v: self.view,
src: randomMoldura(),
image: imageTeste,
x: x,
y: y,
w: width,
h: height)
bubbles.append(bubble_aux)
self.mainBubble!.setDirection()
//self.mainBubble!.restoreDirection()
//self.multiplier += 1
} else {
print("só cheguei até aqui")
}
}
The variable direction
would be responsible for controlling the direction in relation to the main bubble to create the others (it would use a multiplier to create the bubbles in an outer layer the first layer, but this would form a star-like drawing) and not to mention that the second layer would need twice as many objects in relation to the first layer :(.
I'm trying to position the objects in a circular form of a main object.