PicoPicoGameEngine

Quick Links

Sprite Object

ppsprite

.new()

sp = ppsprite.new()

sp : ppsprite object

sp_array = ppsprite.new(n)

n : number

sp_array : object

sp = ppsprite.new(texture_filename)

texture_filename : string

sp : ppsprite object

pptex:default(
  pptex:load("sample.png"))
sp=ppsprite.new()
sp:tile(2)
sp:pos(32,20)

function start()
  sp:draw()
end

:show()

sprite:show()
sprite : sprite object

:hide()

sprite:hide()
sprite : sprite object

:idle()

sprite:idle()
sprite : sprite object

:draw()

sprite:draw()
sprite : sprite object

:isAlive()

result = sprite:isAlive()
sprite : sprite object

  • true
  • false

:isVisible()

result = sprite:isVisible()
sprite : sprite object

  • true
  • false

:pos()

sprite:pos(x,y)
sprite:pos({x,y})
sprite:pos(pos)
pos = sprite:pos()
sprite : sprite object

x : number

y : number

pos : point object

pptex:default(
  pptex:load("sample.png"))
sp=ppsprite.new()
sp:pos(32,20)
sp:pos({32,20})
sp:pos({x=32,y=20})
sp.x,sp.y=32,20

:aabb()

aabb = sprite:aabb()
sprite : sprite object

aabb : pprect object

pptex:default(
  pptex:load("sample.png"))
sp=ppsprite.new()
sp:tile(2)
sp:pos(32,20)

function start()
  sp:pivot(16,16)
  sp:rotate(sp:rotate()+0.01)
  sp:draw()
  ppgraph:box(sp:aabb())
end

:size()

size = sprite:size()
sprite : sprite object

size : pprect object

pptex:default(
  pptex:load("sample.png"))
sp=ppsprite.new()
sp:tile(2)
sp:pos(32,20)
function start()
  sp:draw()
  ppgraph:box(
    sp:size()+sp:pos())
end

:layout()

sprite:layout(autolayout, centerx, centery, [area])
sprite : sprite object

autolayout : boolean

  • true
  • false
centerx : boolean

  • true
  • false
centery : boolean

  • true
  • false
[area] : rectangle object/optional

:texture()

sprite:texture(texture)
sprite:texture(name,[texture_option])
sprite : sprite object

texture : texture object

name : string

[texture_option] : object/optional

:enable()

sprite:enable()
sprite : sprite object

pptex:default(
  pptex:load("sample.png"))
sp=ppsprite.new()
sp:tile(2)
sp:pos(32,20)

function start()
  sp:draw()
  if sp:isAlive() then
    ppgraph:print("Alive")
  end
  if #pptouch() > 0 then
    sp:enable()
  else
    sp:disable()
  end
end

:disable()

sprite:disable()
sprite : sprite object

:move()

sprite:move(x,y)
sprite:move({x,y})
sprite:move(pos)
sprite : sprite object

x : number

y : number

pos : point object

:tileInfo()

sprite:tileInfo(tile_info)
sprite : sprite object

tile_info : object

tile_info={
  size={
    width=[],
    height=[]
  },
  stride={
    x=[],
    y=[]
  },
  offset={
    x=[],
    y=[]
  }
}

:tileSize()

sprite:tileSize(width,height)
sprite:tileSize({width,height})
sprite:tileSize(size)
size = sprite:tileSize()
sprite : sprite object

width : number

height : number

size : object

size={
  width=[],
  height=[]
}

:tileStride()

sprite:tileStride(x,y)
sprite:tileStride({x,y})
sprite:tileStride(stride)
stride = sprite:tileStride()
sprite : sprite object

x : number

y : number

stride : point object

:tileOffset()

sprite:tileOffset(x,y)
sprite:tileOffset({x,y})
sprite:tileOffset(offset)
offset = sprite:tileOffset()
sprite : sprite object

x : number

y : number

offset : point object

:tile()

sprite:tile(index)
index = sprite:tile()
sprite : sprite object

index : number

:rotate()

sprite:rotate(r)
r = sprite:rotate()
sprite : sprite object

r : number

:pivot()

sprite:pivot(x,y)
sprite:pivot({x,y})
sprite:pivot(pivot)
pivot = sprite:pivot()
sprite : sprite object

x : number

y : number

pivot : point object

:flip()

sprite:flip(hflip,vflip,rot90)
hflip,vflip,rot90 = sprite:flip()
sprite : sprite object

hflip : boolean

  • true
  • false
vflip : boolean

  • true
  • false
rot90 : number

:scale()

sprite:scale(x,y)
sprite:scale({x,y})
sprite:scale(scale)
scale = sprite:scale()
sprite : sprite object

x : number

y : number

scale : point object

:alpha()

sprite:alpha(a)
a = sprite:alpha()
sprite : sprite object

a : number

:color()

sprite:color(color)
color = sprite:color()
sprite : sprite object

color : color object

:loopAnime()

sprite:loopAnime(time,tile_array)
sprite : sprite object

time : number

tile_array : object

pptex:default(
  pptex:load("sample.png"))
sp=ppsprite.new()
function start()
  sp:loopAnime(4,{2,3,4,5})
  sp:draw()
end

:playAnime()

done = sprite:playAnime(time,tile_array)
sprite : sprite object

time : number

tile_array : object

done : boolean

:contain()

result = sprite:contain(point)
sprite : sprite object

point : point object

result : boolean

  • true
  • false /li>

:intersect()

result = sprite:intersect(rect)
sprite : sprite object

rect : rectangle object

result : boolean

  • true
  • false

:drag()

sprite:drag(points,[drag_area])
sprite : sprite object

points : objects

[drag_area] : rectangle object/optional

pptex:default(
  pptex:load("sample.png"))
s=ppsprite.new()
s:tile(2)
function start()
  s:drag(pptouch(),
         ppscreen:size())
  s:draw()
end

.x
.y

x = sprite.x
y = sprite.y
sprite.x = x
sprite.y = y
sprite : sprite object

x : number

y : number

.animationTime

.hitlength
.hitmask
.hit

.autolayout
.centerx
.centery