Skip to first unread message
Assigned to by me

Mar 8, 2014, 7:26:29 PM3/8/14
I am making a game (naval battle), and i need to have GRIDS in many formats: 10x11 squares, 10x12 and 14x16 for example. The problem is, when i change the CANVAS Width e Height e drawing a new GRID (row and colunns) the LINES are out of place.. The interesting is if i push the same botton for the second time, everything works fine.
Other thing, if a set the standard Width and Weight of the CANVAS (during development) whith the same size of that Botton (for ex, 10x12 = width 300 x height 360), in this case the Botton works well for the first time.
Seems that changes in the dimensions of the CANVAS do not work immediately, and the program is trying to draw lines in a CANVAS with the last dimensions set.
I tried to repeat twice the MakeGrig procedure in a single call and still doesn't work.

THE GAME IS READY, but I can not ask the player to press the same button twice to select the grid...

Scott Ferguson

Mar 8, 2014, 8:26:20 PM3/8/14
Set the width and height of the Canvas.
Start a Clock Timer.
Inside the Timer block check if the new height (11, 12, 16) is what you are expecting.
If so, then disable the timer and continue processing (draw the lines).
It takes time for the Canvas to readjust it's size and this gives it time to do so.
It doesn't take a noticeable amount of time to the user but the delay is necessary.
Reply all
Reply to author
0 new messages