xcode - Scenekit how to have an X amount of rectangles at different positions? -


for example have variable named x value of 1, means there 1 rectangle. x might become more 1 example 10, , 10 rectangles appear near first one. x 10 might go down example 4 , 4 rectangles disappear? there way this?

this example uses uiview:

let view = uiview(frame: cgrectmake(0, 0, 1024, 768))  view.backgroundcolor = uicolor.graycolor()  let x = 20  in 0 ..< x {      let v = uiview(frame: cgrect(x: 0, y: 0, width: 1024, height: 768))     v.backgroundcolor = uicolor.redcolor()     let xpos = cgfloat(random(20, max: 1000))     let ypos = cgfloat(random(20, max: 700))     v.frame = cgrect(x: xpos, y: ypos, width: 30, height: 30)     view.addsubview(v) } 

but can convert others frameworks spritekit, scenekit. in scenekit add 1 more dimension (z).

if want dinamically change x variable , want view reload can add property observer x variable (didset) , inside simple remove old views , run same code again.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -