Compiling Arrays
Monkey Targets Forums/Android/Compiling Arrays
| ||
Can some kind person please help me out with a little bit of code/help, I want do this: Compiles fine and runs in HTML5, but Android moans about 'Array index out of range'. I read somewhere in these forums you cant do these types of arrays on Android - bit lost at the mo, can anyone come up with an alternative I could use please? |
| ||
Can you provide a complete example including your definition of worldMap? When I create a runnable version of that code it runs without error. |
| ||
Personally I would do this instead so that you're not doing a lot of string slices:worldMap[index] = levelData[index] - 4848 is the ascii value for '0'. |
| ||
I had same problem, change your numbers to asci chars > 32. |
| ||
Judging from the symptoms, Gruk's problem was related to not initialising the "worldMap" array correctly but unless he replies, I guess we'll never know. Javascript and Flash automatically extend their array equivalents if you run off the end, so you can have code that works on those targets but will fail on the others. |
| ||
Work got in the way of pleasure :( But... the above code does work without modification, and 'muddy_shoes' was correct - it was more to do with the general worldmap array. Using 'Global worldmap:Int[levelsize]' - allowed the code to operate properly. Seems dynamic arrays are more than a little tricky to get working on mobile, so I think for now I'll make everything hardcoded. Oh well :) |