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

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -