Skip to content

Commit

Permalink
✨ スクリーンショットの保存先を変数で指定できるように対応,フォーカスが外れた時にポーズするフラグが動作していなかったので修正
Browse files Browse the repository at this point in the history
  • Loading branch information
remyroez committed Jun 24, 2019
1 parent 246cef1 commit fc2ad85
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions game/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,37 @@ local pauseOnUnfocus = true
local focused = true
local screenshot

-- スクリーンショット保存先
local screenshotDirectory = 'screenshot'

-- アプリケーション
local application = (require 'Game')()
application:setDebugMode(debugMode)

-- 読み込み
function love.load()
-- ランダムシードの設定
love.math.setRandomSeed(love.timer.getTime())

-- スクリーンショット保存先の用意
if #screenshotDirectory > 0 then
local dir = love.filesystem.getInfo(screenshotDirectory, 'directory')
if dir == nil then
love.filesystem.createDirectory(screenshotDirectory)
end
end
end

-- 更新
function love.update(dt)
if focused then
if focused or not pauseOnUnfocus then
application:update(dt)
end
end

-- 描画
function love.draw()
if focused or screenshot == nil then
if (focused or screenshot == nil) or not pauseOnUnfocus then
-- 画面のリセット
love.graphics.reset()

Expand All @@ -45,7 +57,7 @@ function love.keypressed(key, scancode, isrepeat)
love.event.quit()
elseif key == 'printscreen' then
-- スクリーンショット
love.graphics.captureScreenshot('' .. os.time() .. '.png')
love.graphics.captureScreenshot((screenshotDirectory .. '/') .. os.time() .. '.png')
elseif key == 'f5' then
-- リスタート
love.event.quit('restart')
Expand Down
2 changes: 1 addition & 1 deletion game/src/Game/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ end

-- 更新
function Game:update(dt, ...)
love.graphics.print('Hello, Game!')
end

-- 描画
function Game:draw(...)
love.graphics.print('Hello, Game!')
end

-- キー入力
Expand Down

0 comments on commit fc2ad85

Please sign in to comment.