Html5开发小游戏看你有多色
来源:互联网 发布:星际争霸2机枪兵数据 编辑:程序博客网 时间:2024/04/29 03:32
极客学院
看你有多色HTML游戏开发视频播放网址:点击打开链接
以下代码为看视频后敲得。可供参考。
1.index.html
<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8"> <title>看你有多色</title> <script src="easeljs-0.7.1.min.js"></script> <script src="Rect.js"></script></head><body> <canvas id="gameView" width="400px" height="400px"></canvas> <script src="app.js"></script></body></html>
2.app.js
var stage=new createjs.Stage("gameView");createjs.Ticker.setFPS(30);createjs.Ticker.addEventListener("tick",stage);var gameView = new createjs.Container();stage.addChild(gameView);var n=2;function addRect() { var cl=parseInt(Math.random()*1000000); var color="#"+cl; var x=parseInt(Math.random()*n); var y=parseInt(Math.random()*n); for(var indexX=0;indexX<n;indexX++){ for(var indexY=0;indexY<n;indexY++){ var r = new Rect(n,color); gameView.addChild(r); r.x=indexX; r.y=indexY if(r.x==x&& r.y==y){ r.setRectType(2); } r.x=indexX*(400/n); r.y=indexY*(400/n); if(r.getRectType()==2){ r.addEventListener("click", function () { if(n<7){ ++n; } gameView.removeAllChildren(); addRect(); }) } } }}addRect();
3.Rect.js
/** * Created by Administrator on 2014/8/9. */function Rect(n,color) { createjs.Shape.call(this); this.setRectType= function (type) { this._RectType=type; switch (type){ case 1: this.setColor(color); break; case 2: this.setColor("#ff0000"); break; } } this.setColor= function (colorString) { this.graphics.beginFill(colorString); this.graphics.drawRect(0,0,400/n-5,400/n-5); this.graphics.endFill(); } this.getRectType= function () { return this._RectType; } this.setRectType(1);}Rect.prototype = new createjs.Shape();
0 0
- Html5开发小游戏看你有多色
- HTML5游戏-看你有多色
- 微信朋友圈HTML5小游戏——看你有多色
- html小游戏——看你有多色
- createjs之easeljs【游戏看你有多色(一)】
- 用canvas写 看你有多色 游戏
- html5 骰子小游戏开发
- 看看你多色
- html5游戏开发,弹球小游戏!!!
- Qt小游戏开发:连连看
- Egret开发HTML5小游戏代码分享
- 如何利用HTML5快速开发一款小游戏
- html5 小游戏
- HTML5小游戏
- 看你有什么需要
- 你有没有看伦敦
- 通关小游戏,看你能过几关
- 写个益智小游戏 看你能过关不?
- 【图解】javaScript组成结构
- leetcode 刷题之路 63 Binary Tree Zigzag Level Order Traversal
- SQL Server事务处理
- hdu-2034-人见人爱A-B
- [zoj3314]CAPTCHA炒鸡大模拟
- Html5开发小游戏看你有多色
- 你应该了解的 一些web缓存相关的概念.
- 删除手机图片后保持图库不会出现黑图的方法。
- ASP.NET获取客户端IP及MAC地址
- MyEclipse 8.5安装Aptana
- android 屏幕适配
- int main(int argc,char* argv[])详解
- POJ--1087--A Plug for UNIX【Dinic】网络最大流
- Linux内核中常用String库函数实现