PKJd index.html 2017-05-19 1st - js do it

PKJbindex.jsenchant();  var SCREEN_W = 640;var SCREEN_H = 640;var G_I="http://jsrun.it/assets/3/D/h/t/3Dht0.png"; var randfloat = function(min, max){ return Math.random()*(max-min)+min;}; window.onload = function() { var game = new Game(SCREEN_W, SCREEN_H); game.preload(G_I); game.onload = function() { var scene = game.rootScene; scene.backgroundColor = "green"; scene.onenterframe = function() { if (game.frame % 30 === 0) { var kuma = new Kuma(); kuma.x = randfloat(0, 640)|0; kuma.y = randfloat(0, 640)|0; scene.addChild(kuma); } }; }; game.start(); }; var createLabel = function(text, x, y, color) { var label = new Label(text); label.moveTo(x, y); label.color = color; label.onenterframe = function() { this.opacity -= 0.01; if (this.opacity <= 0) { this.parentNode.removeChild(this); } }; return label; }; var Kuma = Class.create(Sprite, { initialize: function() { Sprite.call(this, 32, 32); var game = Game.instance; this.image = game.assets[G_I]; this.vx = randfloat(-4, 4)|0; this.vy = randfloat(-4, 4)|0; if (this.vx < 0) this.scaleX *= -1; }, onenterframe: function() { this.x += this.vx; this.y += this.vy; this.frame+=1; this.frame%=4; if (this.x < 0) { this.x = 0; this.vx *= -1; this.scaleX *= -1; } else if(this.x > 640) { this.x = 640; this.vx *= -1; this.scaleX *= -1; } if (this.y < 0) { this.y = 0; this.vy *= -1; } else if (this.y > 640) { this.y = 640; this.vy *= -1; }  }, ontouchstart: function() { var game = Game.instance; var label = createLabel("10点", this.x, this.y, "white"); game.rootScene.addChild(label); this.parentNode.removeChild(this); }}); PKJV mm style.css* { margin: 0; padding: 0; border: 0; } body { background: #ddf; font: 30px sans-serif; }PKJd index.htmlPKJbindex.jsPKJV mm style.cssPKI