Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about OnDraw (using nested for loop)

 
Jeong Ryu
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am making a Game of Life app, and I am having trouble with the nested for loop needed to draw and retain rectangles.
My current code allows me to draw the right size rectangle at the location I touch on the screen, but it does not persist when I click somewhere else.





I know I have to use the nested for loop, but I am having trouble setting it up. Right now, I am setting the coordinates as float X and float Y. I figured that I should use an array or an arraylist, but I am not sure on how to incorporate it.



Could someone please help me? I would appreciate it very much.

Thank you,
-jNova
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My first question (which may or may not have anything to do with the problem) would be: why are i and j of type float, when they seem take on only integer values? How are floats useful for the drawing process?

Beyond that, I'm not clear what the problem is. But yes - you need to store all cells that need drawing somewhere in a data structure, so the onDraw method can draw them all whenever it's called.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic