ScrollView works different on IOs than Android why?

Hi!

im almost done with a word search game, but the problem its that im using a scrollview to determine where is the user clicking at, to select this letter and avoiding to use a lot of them as a button because i was doing this way a was so slow. But The problem is that now im testing on ios and android and on ios work the way it is but on android devices give me an error, i dont know why because its the same code!

why could this happend?

help me plis

what is the error? and do you have code that we can see?

yes! sorry im developing in spanish the quotes and text but the commands are the same, the error its that on android the first letter changes for the second and then the string continuous normal, and on the adb logcat im recieving this error

 Runtime error

I/Corona  (10979): ?:0: attempt to index field ‘?’ (a nil value)

I/Corona  (10979): stack traceback:

I/Corona  (10979): ?: in function ‘_listener’

I/Corona  (10979): ?: in function ‘touch’

I/Corona  (10979): ?: in function <?:424>

I/Corona  (10979): ?: in function <?:221>

I/Corona  (10979): Runtime error

I/Corona  (10979): ?:0: attempt to index field ‘?’ (a nil value)

I/Corona  (10979): stack traceback:

I/Corona  (10979): ?: in function ‘_listener’

I/Corona  (10979): ?: in function ‘touch’

I/Corona  (10979): ?: in function <?:424>

I/Corona  (10979): ?: in function <?:221>

I/Corona  (10979): Runtime error

but on ios console not error are display

my code for the scroll view is this:

-----======variables de donde comenzo en XyY y donde termina en XyY

local comienzoenx

local comienzoeny

local sA=0

local sB=0

local sA2=0

local sB2=0

local DIRECCION

local resulta={}

local anteriorx=0

local anteriory=0

local actualx

local actualy

local function scrollListener(event)

if (event.phase) then

 local phase = event.phase

 if ( phase == “began” ) then 

comienzoenx=retornaX(event.x)

comienzoeny=retornaY(event.y)

if comienzoenx~=nil and comienzoeny~=nil then

sA=comienzoenx

sB=comienzoeny

letras[comienzoenx][comienzoeny].xScale=0.8

letras[comienzoenx][comienzoeny].yScale=0.8

letras[comienzoenx][comienzoeny].disponible=false

formando.text=letras[comienzoenx][comienzoeny].text

formando.x=140*Game.ratiox

else

–return true

end

  

 elseif ( phase == “moved” ) then

if formando.text=="" then --es un began cualquiera

comienzoenx=retornaX(event.x)

comienzoeny=retornaY(event.y)

if comienzoenx~=nil and comienzoeny~=nil then

sA=comienzoenx

sB=comienzoeny

letras[comienzoenx][comienzoeny].xScale=0.8

letras[comienzoenx][comienzoeny].yScale=0.8

letras[comienzoenx][comienzoeny].disponible=false

formando.text=letras[comienzoenx][comienzoeny].text

formando.x=140*Game.ratiox

else

–no hace nada, debemos esperar un clic sobre una posicion real

end

else–ya hay algo escrito

actualx=retornaX(event.x)

actualy=retornaY(event.y)

if actualx ==nil or actualy==nil then

–no hace nada porque se esta moviendo en una posicion fuera de alcance

elseif letras[actualx][actualy].disponible==false then–se esta moviendo en posicion y esta disponible esa letra

–no se hace nada porque se esta usando ya esa letra

elseif sA2==0 and sB2==0 then 

–registramos esta que seria la segunda letra

sA2=actualx

sB2=actualy

anteriorx=actualx

anteriory=actualy

letras[actualx][actualy].xScale=0.8

letras[actualx][actualy].yScale=0.8

letras[actualx][actualy].disponible=false

formando.text=formando.text…letras[actualx][actualy].text

formando.x=140*Game.ratiox

resulta=DETERMINARDIRECCION(sA,sB,sA2,sB2)

–evaluo no se salga del rango

local limitex= letras[actualx][actualy].columna-resulta[“DX”]

local limitey= letras[actualx][actualy].fila-resulta[“DY”]

if limitex>0 and limitex<12 and limitey>0 and limitey<13 then

letras[limitex][limitey].proximo=true

else

print(“out of bounds”)

end

if (star) ~=nil then

star:removeSelf()

star=nil

end

star = display.newLine( letras[comienzoenx][comienzoeny].x, letras[comienzoenx][comienzoeny].y, letras[anteriorx][anteriory].x, letras[anteriorx][anteriory].y )

star:setStrokeColor(0,0,0,1)

star.strokeWidth = 4

star.alpha=0.8

grupo1:insert(star)

star:toBack()

–ya estamos hablando de la tercera letra

elseif letras[actualx][actualy].proximo==true then-- math.abs((actualx-anteriorx))<=1 and math.abs((actualy-anteriory)) then

–evaluamos la ruta de la letra y si es  asi entonces la registramos

–print(“aa”…math.abs((actualx-anteriorx))…"  "…math.abs((actualy-anteriory)))

letras[actualx][actualy].proximo=false–hago falso la mia

–hago proximo la siguiente

–evaluo

local limitex= letras[actualx][actualy].columna-resulta[“DX”]

local limitey= letras[actualx][actualy].fila-resulta[“DY”]

if limitex>0 and limitex<12 and limitey>0 and limitey<13 then

letras[limitex][limitey].proximo=true

else

print(“out of bounds”)

end

–letras[letras[actualx][actualy].columna-resulta[“DX”]][letras[actualx][actualy].fila-resulta[“DY”]].proximo=true

anteriorx=actualx

anteriory=actualy

letras[actualx][actualy].xScale=0.8

letras[actualx][actualy].yScale=0.8

letras[actualx][actualy].disponible=false

formando.text=formando.text…letras[actualx][actualy].text

formando.x=140*Game.ratiox

if (star) ~=nil then

star:removeSelf()

star=nil

end

star = display.newLine( letras[comienzoenx][comienzoeny].x, letras[comienzoenx][comienzoeny].y, letras[anteriorx][anteriory].x, letras[anteriorx][anteriory].y )

star:setStrokeColor(0,0,0,1)

star.strokeWidth = 4

star.alpha=0.8

grupo1:insert(star)

star:toBack()

end

end–si formando.text="" quiere decir que no funciono desde el began

 elseif ( phase == “ended” ) then 

  

  local verifica=quita()

if verifica==false then

formando.text=""

sA=0

sB=0

sA2=0

sB2=0

  actualx=nil

actualy=nil

anteriorx=0

anteriory=0

else

efectopalabra(formando.text)

local tamano=string.len(formando.text)

formando.text=""

local rec

if (star) ~=nil then

star:removeSelf()

star=nil

end

star = display.newLine( letras[comienzoenx][comienzoeny].x, letras[comienzoenx][comienzoeny].y, letras[anteriorx][anteriory].x, letras[anteriorx][anteriory].y )

star:setStrokeColor(0,0,0,1)

star.strokeWidth = 4

star.alpha=0

grupo1:insert(star)

star:toBack()

local losdeltax=math.abs(letras[comienzoenx][comienzoeny].x-letras[anteriorx][anteriory].x)

local losdeltay=math.abs(letras[comienzoenx][comienzoeny].y-letras[anteriorx][anteriory].y)

if losdeltax>losdeltay then

rec=display.newImageRect(“junta”…tamano…".png",(losdeltax+28)+(resulta[“extra”]*(12+losdeltax)),28)

else

rec=display.newImageRect(“junta”…tamano…".png",(losdeltay+28)+(resulta[“extra”]*(12+losdeltay)),28)

end

rec.rotation=resulta[“rotacion”]

rec.x=star.x+(rec.width*resulta[“EX”])

rec.y=star.y+(rec.width*resulta[“EY”])

grupo0:insert(rec)

grupo0:toBack()

rec:setFillColor(colores[totaldepalabras+1][1],colores[totaldepalabras+1][2],colores[totaldepalabras+1][3],colores[1][4])

rec.alpha=0.5

star:removeSelf()

star=nil

sA=0

sB=0

sA2=0

sB2=0

  actualx=nil

actualy=nil

anteriorx=0

anteriory=0

if pencontradas>=pganar then

animacionfin()

end

end

    

    end

end

 sv= widget.newScrollView

{

    top = 4,

    left = 2,

    width = W_-4,

    height = 368+((H_-480)*0.5),

    scrollWidth = 600,

    scrollHeight = 800,

    hideBackground =true,

    backgroundColor = { 0.85, 0.45, 0,1 },

    listener = scrollListener,

    verticalScrollDisabled=true,

  –  horizontalScrollDisabled=true,

}

grupo0:insert(sv)

you should use the <> in this editor to push code up so it is formated etc.

That being said at first glance I cannot see anywhere in the code where your letras “lyrics” variable is being built or declared yet i see you accessing it like it is an object.

The error that adb is throwing is saying as much, it is trying to access letras[x][y] but there is no item with that index which is normally just a matter of it trying to access index 11 when the max is 10 etc. and so forth.

i only take piece of code not he entire one thats why you cant see the declaration of letras={}

i want me to send the code.lua ? where?

what is the error? and do you have code that we can see?

yes! sorry im developing in spanish the quotes and text but the commands are the same, the error its that on android the first letter changes for the second and then the string continuous normal, and on the adb logcat im recieving this error

 Runtime error

I/Corona  (10979): ?:0: attempt to index field ‘?’ (a nil value)

I/Corona  (10979): stack traceback:

I/Corona  (10979): ?: in function ‘_listener’

I/Corona  (10979): ?: in function ‘touch’

I/Corona  (10979): ?: in function <?:424>

I/Corona  (10979): ?: in function <?:221>

I/Corona  (10979): Runtime error

I/Corona  (10979): ?:0: attempt to index field ‘?’ (a nil value)

I/Corona  (10979): stack traceback:

I/Corona  (10979): ?: in function ‘_listener’

I/Corona  (10979): ?: in function ‘touch’

I/Corona  (10979): ?: in function <?:424>

I/Corona  (10979): ?: in function <?:221>

I/Corona  (10979): Runtime error

but on ios console not error are display

my code for the scroll view is this:

-----======variables de donde comenzo en XyY y donde termina en XyY

local comienzoenx

local comienzoeny

local sA=0

local sB=0

local sA2=0

local sB2=0

local DIRECCION

local resulta={}

local anteriorx=0

local anteriory=0

local actualx

local actualy

local function scrollListener(event)

if (event.phase) then

 local phase = event.phase

 if ( phase == “began” ) then 

comienzoenx=retornaX(event.x)

comienzoeny=retornaY(event.y)

if comienzoenx~=nil and comienzoeny~=nil then

sA=comienzoenx

sB=comienzoeny

letras[comienzoenx][comienzoeny].xScale=0.8

letras[comienzoenx][comienzoeny].yScale=0.8

letras[comienzoenx][comienzoeny].disponible=false

formando.text=letras[comienzoenx][comienzoeny].text

formando.x=140*Game.ratiox

else

–return true

end

  

 elseif ( phase == “moved” ) then

if formando.text=="" then --es un began cualquiera

comienzoenx=retornaX(event.x)

comienzoeny=retornaY(event.y)

if comienzoenx~=nil and comienzoeny~=nil then

sA=comienzoenx

sB=comienzoeny

letras[comienzoenx][comienzoeny].xScale=0.8

letras[comienzoenx][comienzoeny].yScale=0.8

letras[comienzoenx][comienzoeny].disponible=false

formando.text=letras[comienzoenx][comienzoeny].text

formando.x=140*Game.ratiox

else

–no hace nada, debemos esperar un clic sobre una posicion real

end

else–ya hay algo escrito

actualx=retornaX(event.x)

actualy=retornaY(event.y)

if actualx ==nil or actualy==nil then

–no hace nada porque se esta moviendo en una posicion fuera de alcance

elseif letras[actualx][actualy].disponible==false then–se esta moviendo en posicion y esta disponible esa letra

–no se hace nada porque se esta usando ya esa letra

elseif sA2==0 and sB2==0 then 

–registramos esta que seria la segunda letra

sA2=actualx

sB2=actualy

anteriorx=actualx

anteriory=actualy

letras[actualx][actualy].xScale=0.8

letras[actualx][actualy].yScale=0.8

letras[actualx][actualy].disponible=false

formando.text=formando.text…letras[actualx][actualy].text

formando.x=140*Game.ratiox

resulta=DETERMINARDIRECCION(sA,sB,sA2,sB2)

–evaluo no se salga del rango

local limitex= letras[actualx][actualy].columna-resulta[“DX”]

local limitey= letras[actualx][actualy].fila-resulta[“DY”]

if limitex>0 and limitex<12 and limitey>0 and limitey<13 then

letras[limitex][limitey].proximo=true

else

print(“out of bounds”)

end

if (star) ~=nil then

star:removeSelf()

star=nil

end

star = display.newLine( letras[comienzoenx][comienzoeny].x, letras[comienzoenx][comienzoeny].y, letras[anteriorx][anteriory].x, letras[anteriorx][anteriory].y )

star:setStrokeColor(0,0,0,1)

star.strokeWidth = 4

star.alpha=0.8

grupo1:insert(star)

star:toBack()

–ya estamos hablando de la tercera letra

elseif letras[actualx][actualy].proximo==true then-- math.abs((actualx-anteriorx))<=1 and math.abs((actualy-anteriory)) then

–evaluamos la ruta de la letra y si es  asi entonces la registramos

–print(“aa”…math.abs((actualx-anteriorx))…"  "…math.abs((actualy-anteriory)))

letras[actualx][actualy].proximo=false–hago falso la mia

–hago proximo la siguiente

–evaluo

local limitex= letras[actualx][actualy].columna-resulta[“DX”]

local limitey= letras[actualx][actualy].fila-resulta[“DY”]

if limitex>0 and limitex<12 and limitey>0 and limitey<13 then

letras[limitex][limitey].proximo=true

else

print(“out of bounds”)

end

–letras[letras[actualx][actualy].columna-resulta[“DX”]][letras[actualx][actualy].fila-resulta[“DY”]].proximo=true

anteriorx=actualx

anteriory=actualy

letras[actualx][actualy].xScale=0.8

letras[actualx][actualy].yScale=0.8

letras[actualx][actualy].disponible=false

formando.text=formando.text…letras[actualx][actualy].text

formando.x=140*Game.ratiox

if (star) ~=nil then

star:removeSelf()

star=nil

end

star = display.newLine( letras[comienzoenx][comienzoeny].x, letras[comienzoenx][comienzoeny].y, letras[anteriorx][anteriory].x, letras[anteriorx][anteriory].y )

star:setStrokeColor(0,0,0,1)

star.strokeWidth = 4

star.alpha=0.8

grupo1:insert(star)

star:toBack()

end

end–si formando.text="" quiere decir que no funciono desde el began

 elseif ( phase == “ended” ) then 

  

  local verifica=quita()

if verifica==false then

formando.text=""

sA=0

sB=0

sA2=0

sB2=0

  actualx=nil

actualy=nil

anteriorx=0

anteriory=0

else

efectopalabra(formando.text)

local tamano=string.len(formando.text)

formando.text=""

local rec

if (star) ~=nil then

star:removeSelf()

star=nil

end

star = display.newLine( letras[comienzoenx][comienzoeny].x, letras[comienzoenx][comienzoeny].y, letras[anteriorx][anteriory].x, letras[anteriorx][anteriory].y )

star:setStrokeColor(0,0,0,1)

star.strokeWidth = 4

star.alpha=0

grupo1:insert(star)

star:toBack()

local losdeltax=math.abs(letras[comienzoenx][comienzoeny].x-letras[anteriorx][anteriory].x)

local losdeltay=math.abs(letras[comienzoenx][comienzoeny].y-letras[anteriorx][anteriory].y)

if losdeltax>losdeltay then

rec=display.newImageRect(“junta”…tamano…".png",(losdeltax+28)+(resulta[“extra”]*(12+losdeltax)),28)

else

rec=display.newImageRect(“junta”…tamano…".png",(losdeltay+28)+(resulta[“extra”]*(12+losdeltay)),28)

end

rec.rotation=resulta[“rotacion”]

rec.x=star.x+(rec.width*resulta[“EX”])

rec.y=star.y+(rec.width*resulta[“EY”])

grupo0:insert(rec)

grupo0:toBack()

rec:setFillColor(colores[totaldepalabras+1][1],colores[totaldepalabras+1][2],colores[totaldepalabras+1][3],colores[1][4])

rec.alpha=0.5

star:removeSelf()

star=nil

sA=0

sB=0

sA2=0

sB2=0

  actualx=nil

actualy=nil

anteriorx=0

anteriory=0

if pencontradas>=pganar then

animacionfin()

end

end

    

    end

end

 sv= widget.newScrollView

{

    top = 4,

    left = 2,

    width = W_-4,

    height = 368+((H_-480)*0.5),

    scrollWidth = 600,

    scrollHeight = 800,

    hideBackground =true,

    backgroundColor = { 0.85, 0.45, 0,1 },

    listener = scrollListener,

    verticalScrollDisabled=true,

  –  horizontalScrollDisabled=true,

}

grupo0:insert(sv)

you should use the <> in this editor to push code up so it is formated etc.

That being said at first glance I cannot see anywhere in the code where your letras “lyrics” variable is being built or declared yet i see you accessing it like it is an object.

The error that adb is throwing is saying as much, it is trying to access letras[x][y] but there is no item with that index which is normally just a matter of it trying to access index 11 when the max is 10 etc. and so forth.

i only take piece of code not he entire one thats why you cant see the declaration of letras={}

i want me to send the code.lua ? where?