bros
I'm making a simple brick styled game using SpriteKit and I'm having a compile time error which says:
Expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions
What I'm trying to do, is, attempting to generate the bricks on the screen using nested for loop which has to yield 5 rows and 6 columns of bricks.
Here is my code:
for var row=0; row<5; row++
{
for var column = 0; column < 6; column++
{
let brick = SKSpriteNode(imageNamed: "brick")
brick.position = CGPoint(x: 2+(brick.size.width/2) + ((brick.size.width + 3) * CGFloat(column)), y: -(2+(brick.size.height/2) + ((brick.size.height + 3) * CGFloat(row))))
self.addChild(brick)
}
}
I tried, splitting up the addition into 2 parts for each X and Y axis, but then I have other problem, the brick's Y position is wrong and is located on the bottom of my screen and overlapping it. Any ideas what should I do? What causes this compile-time error?
I'm using XCode 7.2.1, Swift 2.1.1