Page 1 of 1

[Solved]Loading Files from Another Folder

Posted: Fri Oct 24, 2014 3:15 pm
by shatterblast
I'm trying to tidy up my code and files, but I'm finding that what I thought worked now doesn't. I'm just trying to load graphics from another folder. The error refers to the first line of code. Thanks for any help.

Code: Select all

local saphir_stance_anim = love.graphics.newImage("saphir_graphics/saphir_stance.png")
local saphir_shell_anim = love.graphics.newImage("saphir_graphics/Saphir_Shell_Burst.png")
local saphir_cannon_anim = love.graphics.newImage("saphir_graphics/Saphir_Capacitor_Cannon.png")
local saphir_rally_anim = love.graphics.newImage("saphir_graphics/Saphir_Rally.png")

--______________________________________________________________________

local back_ground = love.graphics.newImage("background01.png")

--______________________________________________________________________

local spritesheet1 = love.graphics.newImage("sparkle_set01.png")
local spritesheet2 = love.graphics.newImage("sparkle_set02.png")
local spritesheet3 = love.graphics.newImage("sparkle_set03.png")

--______________________________________________________________________
  
local animationState_Effects = "Effect_0"
local state_of_saphir = "Effect_Saphir_1"

function love.load()
  require("anal")
  
  spritesheet1:setFilter("nearest", "nearest")
  animation1 = newAnimation(spritesheet1, 192, 192, 0.1, 110)
  --______________________________________________________________________
  
  spritesheet2:setFilter("nearest", "nearest")
  animation2 = newAnimation(spritesheet2, 200, 200, 0.1, 80)
  --______________________________________________________________________
    
  spritesheet3:setFilter("nearest", "nearest")
  animation3 = newAnimation(spritesheet3, 200, 200, 0.1, 80)
  --______________________________________________________________________  
    
  saphir_stance_anim:setFilter("nearest", "nearest")
  --MAKE SURE THE LAST NUMBER IS THE NUMBER OF FRAMES!!!
  saphir_animate_01 = newAnimation(saphir_stance_anim, 156, 248, 0.1, 8)
  
  --______________________________________________________________________
  
  saphir_shell_anim:setFilter("nearest", "nearest")
  --MAKE SURE THE LAST NUMBER IS THE NUMBER OF FRAMES!!!
  saphir_animate_02 = newAnimation(saphir_shell_anim, 203, 248, 0.1, 21)
  
  --______________________________________________________________________
  --animation numbers are wrong
  saphir_canon_anim:setFilter("nearest", "nearest")
  --MAKE SURE THE LAST NUMBER IS THE NUMBER OF FRAMES!!!
  saphir_animate_03 = newAnimation(saphir_canon_anim, 210, 254, 0.1, 21)
  
  --______________________________________________________________________
  --animation numbers are wrong
  saphir_rally_anim:setFilter("nearest", "nearest")
  --MAKE SURE THE LAST NUMBER IS THE NUMBER OF FRAMES!!!
  saphir_animate_04 = newAnimation(saphir_rally_anim, 163, 247, 0.1, 16)
end

function love.update(dt)
  animation1:update(dt)         
  animation2:update(dt)
  animation3:update(dt)
  saphir_animate_01:update(dt)
  saphir_animate_02:update(dt)
  saphir_animate_03:update(dt)
  saphir_animate_04:update(dt)

end

function love.draw()
  love.graphics.draw(back_ground, 0, 0)
  
  love.graphics.print("Press 1, 2, 3, or 4 to alternate between animations.", 50, 50)
  love.graphics.print(animationState_Effects, 50, 110)
  
  if state_of_saphir == "Effect_Saphir_1" then
    saphir_animate_01:setMode("loop")
    saphir_animate_01:draw(600, 150)    
    
  elseif state_of_saphir == "Effect_Saphir_2" then
    saphir_animate_02:setMode("once")
    saphir_animate_02:draw(580, 150)
    
    if saphir_animate_02:getCurrentFrame() == 21 then
      state_of_saphir = "Effect_Saphir_1"
      saphir_animate_01:reset()
      saphir_animate_01:play()  
    end
  end

  --______________________________________________________________________

  if animationState_Effects == "Effect_1" then
    animation1:setMode("once")
    animation1:draw(250, 250)
    
    if animation1:getCurrentFrame() == 110 then
      animationState_Effects = "Effect_0"
    end
       
  elseif animationState_Effects == "Effect_2" then
    animation2:setMode("once")
    animation2:draw(250, 250)
    
    if animation2:getCurrentFrame() == 80 then
      animationState_Effects = "Effect_0"
    end
    
  elseif animationState_Effects == "Effect_3" then
    animation3:setMode("once")
    animation3:draw(250, 250)
    
    if animation3:getCurrentFrame() == 80 then
      animationState_Effects = "Effect_0"
    end
          
  elseif animationState_Effects == "Effect_4" then
    state_of_saphir = "Effect_Saphir_2"          
  end  
end

function love.keypressed(key)
  if key == "1" then
    animationState_Effects = "Effect_1"
    animation1:reset()
    animation1:play()
    
  elseif key == "2" then
    animationState_Effects = "Effect_2"
    animation2:reset()
    animation2:play()
    love.audio.play(sound03)
    
  elseif key == "3" then
    animationState_Effects = "Effect_3"
    animation3:reset()
    animation3:play()
    love.audio.play(sound04)
  
  elseif key == "4" then
    state_of_saphir = "Effect_Saphir_2"
    saphir_animate_02:reset()
    saphir_animate_02:play()
       
  end
end
LOVE file:

https://www.dropbox.com/s/egel7f55aob3s ... .love?dl=0

Re: Loading Files from Another Folder

Posted: Fri Oct 24, 2014 3:20 pm
by Robin
Rename the directory "safir_graphics" to "saphir_graphics". :)

Re: Loading Files from Another Folder

Posted: Fri Oct 24, 2014 4:37 pm
by shatterblast
Robin wrote:Rename the directory "safir_graphics" to "saphir_graphics". :)
Oh gosh. Now I feel embarrassed. Thanks Robin.