base player and romata spritesheet

This commit is contained in:
Sebastian Hugentobler 2014-06-04 14:16:32 +02:00
parent af45552f5f
commit ea83d2431a
14 changed files with 39 additions and 33 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

View File

@ -10,5 +10,6 @@ function Animator:__init(fullWidth, fullHeight)
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)
self.play = anim8.newAnimation(self.animationGrid('1-9', 5), 0.1)
end

View File

@ -29,10 +29,33 @@ function Gridwalker:sendKey(key)
end
end
function Gridwalker:findAnimation(animationName)
local foundAnimation = nil
if animationName == 'up' then
foundAnimation = self.animator.walk_up
elseif animationName == 'down' then
foundAnimation = self.animator.walk_down
elseif animationName == 'right' then
foundAnimation = self.animator.walk_right
elseif animationName == 'left' then
foundAnimation = self.animator.walk_left
elseif animationName == 'play' then
foundAnimation = self.animator.play
end
return foundAnimation
end
function Gridwalker:stopAnimation()
self.animation:pauseAtStart()
end
function Gridwalker:startAnimation(animationName)
self.animation = self:findAnimation(animationName)
self.animation:resume()
end
function Gridwalker:up()
local newX = self.objectinfo.x
local newY = self.objectinfo.y - self.speed
@ -72,18 +95,10 @@ end
function Gridwalker:init()
self.testShape = collider:addRectangle(self.objectinfo.x + self.neighbourOffsetX, self.objectinfo.y + self.neighbourOffsetY, self.collisionTestSize, self.collisionTestSize)
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 = self:findAnimation(self.objectinfo.pose)
self.animation:pauseAtStart()
end

View File

@ -86,6 +86,7 @@ function Engine:initObjects()
local objectinfo = love.filesystem.load(filename)()
objectinfo.x = obj.x - object.width / 4
objectinfo.y = obj.y
objectinfo.name = obj.name
objectinfo.controller.objectinfo = objectinfo
@ -133,3 +134,12 @@ end
function Engine:showMessage(message)
ui:showMessage(message)
end
function Engine:animate(objectName, animationName)
for _, object in ipairs(self.objects) do
if object.name == objectName then
object.controller:startAnimation(animationName)
break
end
end
end

View File

@ -187,18 +187,6 @@ return {
opacity = 1,
properties = {},
objects = {
{
name = "matty",
type = "",
shape = "rectangle",
x = 416,
y = 96,
width = 32,
height = 64,
rotation = 0,
visible = true,
properties = {}
},
{
name = "player",
type = "",

View File

@ -28,7 +28,6 @@
</data>
</layer>
<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>

View File

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

View File

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

View File

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

View File

@ -3,6 +3,7 @@ local story = {}
function story:start(engine)
engine:loadLevel('01')
engine:showMessage('Du befindest dich auf einer sturmgebeutelten Insel. Wo ist denn nur die Milch?')
engine:animate('romata', 'play')
end
return story