kikito / anim8

An animation library for LÖVE
MIT License
730 stars 88 forks source link

Ability to play animations backwards in time #5

Closed kikito closed 11 years ago

kikito commented 11 years ago

Right now the condition of dt being posititive is pretty much "hard-coded" into anim8. The culprint is the update method:

function Animation:update(dt)
  if self.status ~= "playing" then return end

  self.timer = self.timer + dt

  while self.timer > self.delays[self.position] do
    self.timer = self.timer - self.delays[self.position]
    self.position = self.position + self.direction
    if self.position < 1 or self.position > #self.frames then
      self:endSequence()
    end
  end
end

It would be cool if animation:update admitted negative dts. This way we could use it in games that involve time manipulation (like in Braid).

kikito commented 11 years ago

anim8 is able to run animations backwards since v2.0