31 lines
1.1 KiB
Lua
31 lines
1.1 KiB
Lua
|
|
require "entity"
|
||
|
|
|
||
|
|
-- An editor annotation dropped onto the grid. A Note is a normal Entity (so it
|
||
|
|
-- serializes, places and hit-tests like any other object) that carries a bit of
|
||
|
|
-- author text. It is deliberately non-collidable — the player passes straight
|
||
|
|
-- through it — and only ever renders as a translucent icon while the editor is
|
||
|
|
-- available (DEBUG) and notes are toggled on (see NOTES_VISIBLE / Room:draw).
|
||
|
|
Note = class("Note", Entity)
|
||
|
|
|
||
|
|
local noteSprite = loadSprite("art/_debug/notepad.png")
|
||
|
|
|
||
|
|
function Note:initialize(x, y, text)
|
||
|
|
self.text = text or ""
|
||
|
|
self.saveClass = "note"
|
||
|
|
Entity.initialize(self, {
|
||
|
|
x = x, y = y,
|
||
|
|
color = "white", -- representative only; Note:draw ignores channels
|
||
|
|
collision = "none",
|
||
|
|
sprite = noteSprite,
|
||
|
|
})
|
||
|
|
end
|
||
|
|
|
||
|
|
-- Drawn once (not per-channel) as a faint overlay. Called directly from the
|
||
|
|
-- room's note pass, so it takes no channel argument.
|
||
|
|
function Note:draw()
|
||
|
|
love.graphics.setColor(1, 1, 1, 0.85)
|
||
|
|
local p = self:getDrawPos()
|
||
|
|
love.graphics.draw(self.sprite, p.x, p.y, 0, drawScale, drawScale)
|
||
|
|
love.graphics.setColor(1, 1, 1, 1)
|
||
|
|
end
|