Skip to content

Commit 004ceed

Browse files
committed
📝 mention isKeyJustPressed in the manual
1 parent 6605f21 commit 004ceed

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

docs/user-manual.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ function Update()
245245
if isSpacePressed then
246246
Graphics.drawRect(Vec.V2(0, 0), Vec.V2(0.1, 0.2), Vec4.RED)
247247
end
248+
249+
-- If you need to perform something only once when a key is pressed, you can use `isKeyJustPressed`
250+
if Io.isKeyJustPressed("r") then
251+
Debug.print("R was just pressed!")
252+
end
253+
248254
-- Print pressed keys
249255
Debug.fprint(Io.getKeysDown())
250256
-- Print which mouse buttons are pressed
@@ -356,13 +362,13 @@ local Loader = require("@vectarine/loader")
356362
local Vec = require("@vectarine/vec")
357363
local Coord = require("@vectarine/coord")
358364

359-
local imageResource = Loader.loadImage("textures/my_image.png")
365+
local myImage = Loader.loadImage("textures/my_image.png")
360366

361367
function Update()
362-
if imageResource:isReady() then
368+
if myImage:isReady() then
363369
-- Draw the image at the center of the screen with size 200x200 pixels
364370
local size = Coord.pxDelta(Vec.V2(200, 200))
365-
imageResource.draw(Coord.gl(Vec.ZERO2) - size:scale(0.5), size)
371+
myImage:draw(Coord.gl(Vec.ZERO2) - size:scale(0.5), size)
366372
end
367373
end
368374
```
@@ -384,7 +390,7 @@ local Loader = require("@vectarine/loader")
384390
local Text = require("@vectarine/text")
385391
local Vec = require("@vectarine/vec")
386392

387-
local fontResource = Loader.loadImage("fonts/my_font.ttf")
393+
local fontResource = Loader.loadFont("fonts/my_font.ttf")
388394

389395
function Update()
390396
if not fontResource:isReady() then
@@ -393,14 +399,14 @@ function Update()
393399
-- Using your own font:
394400
fontResource:drawText("Hello", Vec.V2(0, 0), 0.16)
395401

396-
-- Using the default font
402+
-- Or using the default font (Roboto)
397403
Text.font:drawText("world", Vec.V2(0, -0.16), 0.16)
398404
end
399405
```
400406

401407
## Sound and Music
402408

403-
Loading sounds works just like Images, but you call the `loadAudio` function instead of `loadImage`.
409+
Loading sounds works just like images, but you call the `loadAudio` function instead of `loadImage`.
404410

405411
# ✂️ Splitting and organizing your code
406412

0 commit comments

Comments
 (0)