new spritesheet format

This commit is contained in:
Sebastian Hugentobler 2014-06-04 10:36:42 +02:00
parent 203f111b8a
commit af45552f5f
9 changed files with 40 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

View File

@ -6,9 +6,9 @@ Animator = class()
function Animator:__init(fullWidth, fullHeight)
self.animationGrid = anim8.newGrid(object.width, object.height, fullWidth, fullHeight)
self.walk_up = anim8.newAnimation(self.animationGrid('1-9', 9), 0.1)
self.walk_left = anim8.newAnimation(self.animationGrid('1-9', 10), 0.1)
self.walk_down = anim8.newAnimation(self.animationGrid('1-9', 11), 0.1)
self.walk_right = anim8.newAnimation(self.animationGrid('1-9', 12), 0.1)
self.walk_up = anim8.newAnimation(self.animationGrid('1-9', 1), 0.1)
self.walk_left = anim8.newAnimation(self.animationGrid('1-9', 2), 0.1)
self.walk_down = anim8.newAnimation(self.animationGrid('1-9', 3), 0.1)
self.walk_right = anim8.newAnimation(self.animationGrid('1-9', 4), 0.1)
end

View File

@ -74,7 +74,17 @@ function Gridwalker:init()
collider:setPassive(self.testShape)
self.animator = Animator:new(self.objectinfo.image:getWidth(), self.objectinfo.image:getHeight())
if self.objectinfo.pose == 'up' then
self.animation = self.animator.walk_up
elseif self.objectinfo.pose == 'down' then
self.animation = self.animator.walk_down
elseif self.objectinfo.pose == 'right' then
self.animation = self.animator.walk_right
elseif self.objectinfo.pose == 'left' then
self.animation = self.animator.walk_left
end
self.animation:pauseAtStart()
end

View File

@ -210,6 +210,18 @@ return {
rotation = 0,
visible = true,
properties = {}
},
{
name = "romata",
type = "",
shape = "rectangle",
x = 320,
y = 160,
width = 32,
height = 64,
rotation = 0,
visible = true,
properties = {}
}
}
},

View File

@ -30,6 +30,7 @@
<objectgroup name="objects">
<object name="matty" x="416" y="96" width="32" height="64"/>
<object name="player" x="320" y="480" width="32" height="64"/>
<object name="romata" x="320" y="160" width="32" height="64"/>
</objectgroup>
<layer name="overlay" width="20" height="20">
<data encoding="base64" compression="zlib">

View File

@ -2,7 +2,7 @@ local object = require "engine/object"
local gridwalker = require "engine/controllers/gridwalker"
return {
spritesheet = "assets/characters/matty.png",
pose = object.walking_down,
spritesheet = "assets/characters/romata.png",
pose = 'down',
controller = Gridwalker()
}

View File

@ -2,8 +2,8 @@ local object = require "engine/object"
local gridwalker = require "engine/controllers/gridwalker"
return {
spritesheet = "assets/characters/player.png",
pose = object.walking_up,
spritesheet = "assets/characters/romata.png",
pose = 'up',
controller = Gridwalker(),
relevantKeys = {
"w", "up",

8
src/objects/romata.lua Normal file
View File

@ -0,0 +1,8 @@
local object = require "engine/object"
local gridwalker = require "engine/controllers/gridwalker"
return {
spritesheet = "assets/characters/romata.png",
pose = 'left',
controller = Gridwalker()
}