2
I am trying in many ways and I am not succeeding, I have managed in a way that will not be viable, someone knows how I could do more in this idea take the central position of the circle and calculate points(x, y) that are 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 relative to the main bubble to create the others (would use a multiplier to create the bubbles in an outer layer the first layer, but with this would form a drawing similar to a star) and not to mention that the second layer would need twice as many objects as the first layer :(.
I’m trying to position the circular objects of a main object.
yes but Voce has to harvest parts of what you’ve tried, and what you’re thinking and do.
– jsbueno