Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 17th, 2012  |  syntax: JavaScript  |  size: 1.36 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  5. <script type="text/javascript" src="http://cdn.craftycomponents.com/crafty-dev.js"></script>
  6. <script type="text/javascript">
  7. $(function(){
  8. Crafty.init()
  9.    
  10. Crafty.scene("main", function() {
  11.     Crafty.modules('http://cdn.craftycomponents.com', {
  12.         Joystick: "dev"
  13.     }, function() {
  14.         var stick = Crafty.e("2D, DOM, Image").attr({
  15.             x: 55,
  16.             y: 55,
  17.             w: 50,
  18.             h: 50,
  19.             z: 1
  20.         }).image("http://cdn1.iconfinder.com/data/icons/function_icon_set/circle_green.png");
  21.  
  22.         var track = Crafty.e("2D, DOM, Image, Joystick, Text").attr({
  23.             x: 50,
  24.             y: 50,
  25.             w: 64,
  26.             h: 64       }).image("http://cdn1.iconfinder.com/data/icons/softwaredemo/PNG/64x64/Circle_Grey.png").text('joystick')
  27.             .joystick(stick,{mouseSupport: true, range: 20 });
  28.  
  29.         var movedBox = Crafty.e("2D, DOM, Color, Keyboard, Multiway, Text").attr({
  30.             x: 150,
  31.             y: 150,
  32.             w: 50,
  33.             h: 50
  34.         }).color('red').text('object')
  35.         .multiway(5, {UP_ARROW: -90, DOWN_ARROW: 90, RIGHT_ARROW: 0, LEFT_ARROW: 180});
  36. });
  37.  
  38. })
  39. Crafty.scene("main");
  40.  
  41. });
  42. </script>
  43. </head>
  44. </html>