PK•Jbss index.html enchant.js ブロック崩しもどき - js do it PK•J(index.jsenchant(); window.onload = function(){ var w = 460; var h = 460; var game = new Game(w, h); game.fps = 60; game.preload('http://jsrun.it/assets/k/1/7/X/k17X3.gif','http://jsrun.it/assets/l/P/W/m/lPWmO.gif', "http://jsrun.it/assets/c/Y/M/y/cYMy7.png"); game.onload = function(){ var ball = new Sprite(11, 11); ball.image = game.assets['http://jsrun.it/assets/k/1/7/X/k17X3.gif']; ball.x = 20; ball.y = 200; ball.dx = 4; ball.dy = 4; ball.wait = 0; ball.addEventListener('enterframe', function(){ this.x += this.dx; this.y += this.dy; if(0 > this.x || w-20 < this.x) this.dx = - this.dx; if(0 > this.y || h-20 < this.y) this.dy = - this.dy; if(ball.intersect(pad)){ this.dy = - this.dy; } }); game.rootScene.addChild(ball); var pad = new Sprite(60,8); pad.image = game.assets['http://jsrun.it/assets/l/P/W/m/lPWmO.gif']; pad.x = 210; pad.y = 420; pad.nx = 210; pad.addEventListener('enterframe', function(){ pad.moveTo(this.nx, this.y); }); game.rootScene.addChild(pad); var blocks = new Group(); for(var i=0; i< 8;i++){ var bw = 0; for(var j=0;j<26;j++){ var block = new Sprite(16, 16); block.image = game.assets['http://jsrun.it/assets/c/Y/M/y/cYMy7.png']; block.x = 16 + bw; block.y = 16 * i; block.addEventListener('enterframe', function(){ if(this.intersect(ball)){ ball.dy = - ball.dy; this.remove(); } }); blocks.addChild(block); bw = bw + 16; } } game.rootScene.addChild(blocks); game.rootScene.addEventListener("touchmove", function(e) { pad.nx = e.x - (pad.width/2); }); } game.start(); } PK•J`-d style.cssbody { margin:0px; } PK•Jbss index.htmlPK•J(index.jsPK•J`-d { style.cssPK