Advertisement
Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

HTML5 Game Development: Adding Buttons with the GameButton Object

Part of the HTML5 Game Development For Dummies Cheat Sheet

If your game only allows keyboard input, users with touchscreen devices may not be able to play. Use the gameButton object to add touchscreen-supported buttons.

buttonName = new GameButton(label); Creates a GameButton object called buttonName displaying the label value. The label value can include HTML code for more interesting buttons.
setPosition(x,y) Sets the button's upper-left corner to the indicated (x,y) coordinates. The coordinates are for the page, so buttons can be placed on the game scene or elsewhere on the page.
setSize(width, height) Changes the button's size. You may need to experiment to find the optimal button size for easy play without obscuring the screen.
isClicked() Returns true if the button is currently clicked and false if it is not. Provides an easy way to read the button's status in the game loop.
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win an iPad Mini. Enter to win now!