isPressingSpace() reports whether the player is pressing the spacebar. Check it in a ship’s next() hook to decide whether to fire; throttling the firing function slows repeated shots across fast-rendering frames. section 29.3
next() {
super.next(); 1
if (isPressingSpace()) { 2
this.fire(); 3
}
return this; 4
}
!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":1,\"ch\":36},{\"line\":1,\"ch\":37}],[{\"line\":3,\"ch\":36},{\"line\":3,\"ch\":37}],[{\"line\":4,\"ch\":36},{\"line\":4,\"ch\":37}],[{\"line\":7,\"ch\":36},{\"line\":7,\"ch\":37}]]"}
!@%STYLE%@!
The ship checks the helper during each frame update and calls fire() when the spacebar is pressed. section 29.3
