Book Image

MooTools 1.2 Beginner's Guide

Book Image

MooTools 1.2 Beginner's Guide

Overview of this book

MooTools is a simple-to-use JavaScript library, ideal for people with basic JavaScript skills who want to elevate their web applications to a superior level. If you're a newcomer to MooTools looking to build dynamic, rich, and user-interactive web site applications this beginner's guide with its easy-to-follow step-by-step instructions is all you need to rapidly get to grips with MooTools.
Table of Contents (14 chapters)
MooTools 1.2 Beginner's Guide
Credits
About the Authors
About the Reviewer
Preface

Time for action—creating a simple drag-and-drop game


We're going to create a web game that will utilize the Drag and Drag.Move plugins. There will be a small gray box that you can drag around the web page (called a draggable). There will also be a larger box to drag to (called a droppable). When the draggable is dropped inside the droppable, you get 1 point.

  1. First, we will set up the HTML. We contain the draggable and droppable elements inside a div called #drag-container. The draggable element will have an ID of #draggable and the droppable element will have an ID of #dropbox. Finally, we have a section for placing the user's score called #log.

    <body>
    <h1>Drag and Drop</h1>
    <p><strong>Instructions</strong>: drag the smaller gray box inside the larger box. You get 1 point for each successful drop.</p>
    <div id="drag-container">
    <div id="draggable">&nbsp;</div>
    <div id="dropbox">Drag stuff here.</div>
    </div>
    ...