PicoPicoGameEngine

Quick Links

Tiled Map Object

ppmap

Subclass of ppsprite.

.new()

map = ppmap.new()
map_array = ppmap.new(n)
map : ppmap object

n : number

map_array : object

:load()

map:load(tmx_filename,[texture_option])
map : ppmap object

tmx_filename : string

[texture_option] : object/optional

map = ppmap.new()
map:load("map1.tmx")
function start()
  map:draw()
end

:clip()

map:clip(x,y,width,height)
map:clip({x,y,width,height})
map:clip(area)
area = map:clip()
map : ppmap object

x : number

y : number

width : number

height : number

area : rectangle object

map = ppmap.new()
map:load("map1.tmx")
map:clip(2,2,8,12)
function start()
  map:draw()
end

:reset()

map:reset()
map : ppmap object

:layerList()

list = map:layerList()
map : ppmap object

list : string object array

:addLayer()

map:addLayer(name,width,height)
map:addLayer(name,{width,height})
map:addLayer(name,size)
map : ppmap object

name : string

width : number

height : number

size : rectangle object

:tileset()

tileset = map:tileset()
map : ppmap object

tileset : object

map = ppmap.new()
map:load("map1.tmx")

function start()
  map:draw()
  local t=map:tileset()
  for k,v in pairs(t) do
    ppgraph:print(
      v.firstgid..","..
      v.name..","..
      v.tilewidth..","..
      v.tileheight)
    ppgraph:move(0,16)
  end
end

:layer()

map:layer(name)
layer = map:layer()
map : ppmap object

name : string

layer : number

:show()

map:show()
map:show(layer)
map : ppmap object

layer : number

map = ppmap.new()
map:load("map1.tmx")

map:layer("layer2")
map:hide(map:layer())

map:layer("layer1")
map:show(map:layer())

function start()
  map:draw()
end

:hide()

map:hide()
map:hide(layer)
map : ppmap object

layer : number

:locate()

map:locate(x,y)
map:locate({x,y})
map:locate(pos)
pos = map:locate()
map : ppmap object

x : number

y : number

pos : point object

:tile()

tile = map:tile()
tile = map:tile(x,y)
tile = map:tile({x,y})
tile = map:tile(pos)
map : ppmap object

x : number

y : number

pos : point object

tile : number

map = ppmap.new()
map:load("map1.tmx")
map:layer("layer2")
function start()
  map:draw()
  local p = pptouch()[1]
  if p==nil then
    p=pppoint(0,0)
  end
  ppgraph:print(
    map:tile(p/32))
end

:tile()

map:tile(tile)
map:tile(x,y,tile)
map:tile({x,y},tile)
map:tile(pos,tile)
map : ppmap object

x : number

y : number

pos : point object

tile : number

map = ppmap.new()
map:load("map1.tmx")
map:layer("layer2")
function start()
  map:draw()
  local p = pptouch()[1]
  if p~=nil then
    map:tile(p/32,5)
  end
end

:clear()

map:clear()
map:clear(tile)
map : ppmap object

tile : number

:mapSize()

map:mapSize(width,height)
map:mapSize({width,height})
map:mapSize(size)
size = map:mapSize()
map : ppmap object

width : number

height : number

size : rectangle object

:print()

map:print(string)
map : ppmap object

string : string

map = ppmap.new()
map:load("map1.tmx")

--change texture
map:texture(
  ppfont:texture())
map:tileSize(8,8)
map:scale(2)

--clear layer2
map:layer("layer2")
map:clear()

--clear layer1
map:layer("layer1")
map:clear()

--change layer1 size
map:mapSize(20,20)
map:area(0,0,20,20)

--print HELLO WORLD
map:locate(1,1)
map:print("HELLO WORLD")

function start()
  map:draw()
end

:fill()

map:fill(x,y,width,height,tile)
map:fill({x,y,width,height},tile)
map:fill(rect,tile)
map : ppmap object

tile : number

x : number

y : number

width : number

height : number

rect : rectangle object

:box()

map:box(x,y,width,height,tile)
map:box({x,y,width,height},tile)
map:box(rect,tile)
map : ppmap object

tile : number

x : number

y : number

width : number

height : number

rect : rectangle object

:circle()

:circle(x,y,r,tile,[start],[end])
:circle({x,y},r,tile,[start],[end])
:circle(pos,r,tile,[start],[end])
map : ppmap object

tile : number

x : number

y : number

pos : point object

r : number

[start] : number/optional

[end] : number/optional

:line()

map:line(x1,y1,x2,y2,tile)
map:line({x1,y1},{x2,y2},tile)
map:line(pos1,pos2,tile)
map : ppmap object

tile : number

x1 : number

y1 : number

x2 : number

y2 : number

pos1 : point object

pos2 : point object

:paint()

map:paint(x,y,tile)
map:paint({x,y},tile)
map:paint(pos,tile)
map : ppmap object

tile : number

x : number

y : number

pos : point object

:swap()

map:swap(tile1,tile2)
map : ppmap object

tile1 : number

tile2 : number

:scroll()

map:scroll(dx,dy)
map:scroll({dx,dy})
map:scroll(delta)
map : ppmap object

dx : number

dy : number

delta : point object

map = ppmap.new()
map:load("map1.tmx")
map:layer("layer1")
map:scroll(0,6)
map:layer("layer2")
map:scroll(0,6)
function start()
  map:draw()
end

:copy()

map:copy(x,y,width,height,{dst_x,dst_y}})
map:copy({x,y,width,height},{dst_x,dst_y})
map:copy(rect,{dst_x,dst_y})
map : ppmap object

x : number

y : number

width : number

height : number

rect : rectangle object

dst_x : number

dst_y : number

:attribute()

map:attribute(attr)
map : ppmap object

attr : object

{
  hflip=[ boolean],
  vflip=[ boolean],
  rotate90=[],
  color=[ color object]}
map = ppmap.new()
map:load("map1.tmx")
map:layer("layer1")
map:attribute({rotate90=3})
local w=map:mapSize().width
local h=map:mapSize().height
for y=0,h-1 do
  for x=0,w-1 do
    map:locate(x,y)
    local t=map:tile()
    map:tile(t)
  end
end
function start()
  map:draw()
end

:resetAttribute()

map:resetAttribute()
map : ppmap object

:check()

result = map:check( tile, tile_array)

map : ppmap object

tile_array : object

result : boolean

  • true
  • false
result = map:check( tile, char_from, char_to)

map : ppmap object

char_from : number

char_to : number

result : boolean

  • true
  • false

:mapInfo()

map:mapInfo(mapInfoObject)
mapInfo = map:mapInfo()
map : ppmap object

:objectGroupList()

group_name_array = map:objectGroupList()
group_name_array : string object array

:objectList()

object_info_array = map:objectList(group_name)
group_name : string

group name

object_info_array : map object info array

  • x
  • y
  • width
  • height
  • name
  • type
  • gid

:objectInfo()

object_info = map:objectInfo(group_name,index)
group_name : string

group name

index : number

index number

object_info : map object info

  • x
  • y
  • width
  • height
  • name
  • type
  • gid

:objectIndex()

index = map:objectIndex(group_name,object_name)
index : number

index number

group_name : string

group name

object_name : string

object name