searching tuto for moving a character from cell to cell on a grid

hello,

All my request is in my topic title.

Tkanks.

Hello,

What you could do is to set an event listener on each cell this isn’t active (for example by setting on property on the cell like isEnable)

Then set a event listener to your character and when you tap it, change the isEnable on the cell you would allow him to move, so the next tap on the enabled cell would move the character.

Thanks but could you explain with a part of code. I don’t see cell like enable…

there is no functions available from corona to create a cell grid in your app. Probably it is best to create one yourself, as not everyone else is always using this method for moving a character, for example. You also need to specify what kind of method you want to achieve, what you have done, and what problems are you facing. No one is going to reply if less information are being given.

From what I assume (from your topic title), you wanted to create a grid of cells, that detect each time character moves into a certain cell. what you need to do is to create the grid of cells first. Let’s take an iPad for an example. let’s say you want to divide its screen resolution of 1024x768 into 6x3 cells, with 6 cells width and 3 cells height. You can either use a rect to put touch listeners on each cells, or create one big rect to cover the screen, and then decide accordingly using if statements based on which position the touch event is. from there, you can write your own code on how to behave your character when the touch listener is triggered.

Hope that helps.

Thanks for this information but is it impossible to have with a listener the return of the cell touched ? If i have this return for example : myGrid[1][3] I could move my character to the cell [1][3]…

below i put my code for my grid

local myGrid = {} local row = 10 local cell = 15 local rectx = 30 local recty = 30 local gridscaley = 0.35 local gridscalex = 0.35 local space = 2 local spaceleft =10 local spaceright = 50 local image = "myx.png"     for i = 1, cell do         myGrid[i] = {};         for k = 1, row do             myGrid[i][k] = display.newImage(image)             myGrid[i][k].yScale=0.35             myGrid[i][k].xScale=0.35             myGrid[i][k].alpha = 1             myGrid[i][k].x = (k - 1) \* (rectx + space) + spaceleft             myGrid[i][k].y = (i - 1) \* (recty + space) + spaceright                  end end myGrid.touch = function ( self, event ) end Runtime:addEventListner( "touch", myGrid )

if the code serves me right, you haven’t put any functionality on your listener, here,

myGrid.touch = function ( self, event ) end

you need to specify each phases on touch. Reminding that touch listeners have several phases, it is important to define each of the phases, and what will happen when the device receive that phase.

Hello,

What you could do is to set an event listener on each cell this isn’t active (for example by setting on property on the cell like isEnable)

Then set a event listener to your character and when you tap it, change the isEnable on the cell you would allow him to move, so the next tap on the enabled cell would move the character.

Thanks but could you explain with a part of code. I don’t see cell like enable…

there is no functions available from corona to create a cell grid in your app. Probably it is best to create one yourself, as not everyone else is always using this method for moving a character, for example. You also need to specify what kind of method you want to achieve, what you have done, and what problems are you facing. No one is going to reply if less information are being given.

From what I assume (from your topic title), you wanted to create a grid of cells, that detect each time character moves into a certain cell. what you need to do is to create the grid of cells first. Let’s take an iPad for an example. let’s say you want to divide its screen resolution of 1024x768 into 6x3 cells, with 6 cells width and 3 cells height. You can either use a rect to put touch listeners on each cells, or create one big rect to cover the screen, and then decide accordingly using if statements based on which position the touch event is. from there, you can write your own code on how to behave your character when the touch listener is triggered.

Hope that helps.

Thanks for this information but is it impossible to have with a listener the return of the cell touched ? If i have this return for example : myGrid[1][3] I could move my character to the cell [1][3]…

below i put my code for my grid

local myGrid = {} local row = 10 local cell = 15 local rectx = 30 local recty = 30 local gridscaley = 0.35 local gridscalex = 0.35 local space = 2 local spaceleft =10 local spaceright = 50 local image = "myx.png"     for i = 1, cell do         myGrid[i] = {};         for k = 1, row do             myGrid[i][k] = display.newImage(image)             myGrid[i][k].yScale=0.35             myGrid[i][k].xScale=0.35             myGrid[i][k].alpha = 1             myGrid[i][k].x = (k - 1) \* (rectx + space) + spaceleft             myGrid[i][k].y = (i - 1) \* (recty + space) + spaceright                  end end myGrid.touch = function ( self, event ) end Runtime:addEventListner( "touch", myGrid )

if the code serves me right, you haven’t put any functionality on your listener, here,

myGrid.touch = function ( self, event ) end

you need to specify each phases on touch. Reminding that touch listeners have several phases, it is important to define each of the phases, and what will happen when the device receive that phase.