Book Image

HTML5 Game Development by Example: Beginner's Guide

By : Seng Hin Mak
Book Image

HTML5 Game Development by Example: Beginner's Guide

By: Seng Hin Mak

Overview of this book

Table of Contents (18 chapters)
HTML5 Game Development by Example Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
9
Building a Physics Car Game with Box2D and Canvas
Index

Time for action – moving a playing card around


In this example, we will place two playing cards on a web page and transform them to a different position, scale, and rotation. We will tween the transformation by setting the transition:

  1. To do this, create a new project folder with the following hierarchy. The css3transition.css and index.html files are empty now and we will add the code later. The jquery-2.1.3.min.js file is the jQuery library that we used in the previous chapter.

    index.html
    js/
      js/jquery-2.1.3.js
    css/
      css/css3transition.css
    images/
  2. We are using two playing card graphic images in this example. They are AK.png and AQ.png. The images are available in the code bundle or you can download them from the book assets website at http://mak.la/book-assets/.

  3. Put the two card images inside the images folder.

  4. The next thing is to code the HTML with two card DIV elements. We will apply CSS transition style to these two cards elements when the page is loaded:

    <!DOCTYPE html>
    <html...