Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NGUI examples
#8
Quick reply here. If you change your file to:

Code:
[[0,0,1,0,0,1,0,0],
[0,0,1,0,0,1,0,0],
[0,1,1,1,1,1,1,0],
[1,1,1,0,0,1,1,1],
[0,0,1,1,1,1,0,0],
[0,1,1,1,1,1,1,0],
[0,1,0,0,0,0,1,0],
[1,0,0,0,0,0,0,1]]

, it becomes a valid json that you can load with JSON_FromFile if you include the json library. JSON_FromFile will return a 2D array in this case.

Code:
include "json.n7"

data = JSON_FromFile("sprite.txt")
' Get width and height.
h = sizeof(data)
w = sizeof(data[0])
for y = 0 to h - 1
    for x = 0 to w - 1
        ' Access value for x, y.
        value = data[y][x]
    next
next

This code doesn't do anything, it just shows you how to get the value at x, y.
Reply


Messages In This Thread
NGUI examples - by Marcus - 01-21-2024, 03:15 PM
RE: NGUI examples - by kevin - 01-21-2024, 05:07 PM
RE: NGUI examples - by 1micha.elok - 01-30-2024, 03:46 AM
RE: NGUI examples - by Marcus - 01-30-2024, 09:40 PM
RE: NGUI examples - by 1micha.elok - 02-01-2024, 09:29 AM
RE: NGUI examples - by kevin - 01-31-2024, 02:32 PM
RE: NGUI examples - by Marcus - 01-31-2024, 04:11 PM
RE: NGUI examples - by Marcus - 02-01-2024, 01:45 PM
RE: NGUI examples - by 1micha.elok - 02-05-2024, 09:09 AM

Forum Jump:


Users browsing this thread: 4 Guest(s)