zim编写一个颜色对对碰小游戏效果代码

代码语言:html

所属分类:游戏

代码描述:zim编写一个颜色对对碰小游戏效果代码

代码标签: 颜色 对对 小游戏 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="UTF-8">






</head>

<body>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/createjs-1.3.2.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/zim-cat.3.js"></script>

    <script>
const frame = new Frame("fit", 1024, 768, black, darker);
frame.on("ready", ()=>{ // ES6 Arrow Function - similar to function(){}
	zog("ready from ZIM Frame"); // logs in console (F12 - choose console)

	// often need below - so consider it part of the template
	const stage = frame.stage;
	const stageW = frame.width;
	const stageH = frame.height;

	// REFERENCES for ZIM at https://zimjs.com
	// see https://zimjs.com/intro.html for an intro example
	// see https://zimjs.com/learn.html for video and code tutorials
	// see https://zimjs.com/docs.html for documentation
	// see https://codepen.io/topic/zim/ for ZIM on CodePen
	
	// *** NOTE: ZIM Cat defaults to time in seconds
	// All previous versions, examples, videos, etc. have time in milliseconds
	// This can be set back with TIME = "milliseconds" but we suggest you give it a try!
	// There will be a warning in the conslole if your animation is not moving ;-)

	// CODE HERE
	
	// A classic concentration-like card-flipping game
	// Could easily add picture and sound assets - see https://zimjs.com/elearning/quiz.html
	
	new Label("T E T R A D I C   C O N C E N T R A T I O N", 22, null, light).pos(null,40,CENTER);
	new Label("Made with ZIM", 22, null, light, yellow)
		.cur()
		.pos(0,40,CENTER,BOTTOM)
		.tap(()=>{zgo("https://zimjs.com","_blank")});

	const colors = ["#1E00FF","#FF0061","#E1FF00","#00FF9E"];
	let answers = shuffle(colors.concat(colors,colors,colors)); // four sets or two sets of matches
	let index = 0;
	
	function makeCard() {
		let front = stage.frame.makeIcon().sca(1.1);
		let answer = answers[index++];
		let back = new Rectangle(front.width,front.height,answer);
		let card = new Flipper(front, back, null, null, null, null, null, false, false).centerReg({add:false});
		card.answer = answer; // store on card for ease of collection
		return card;
	}

	const cards = new Tile({
		obj:makeCard,
		cols:4,
		rows:4,
		spacingH:20,
		spacingV:15,
		clone:false // so keeps proper answer
	}).center().cur();

	let cardCount = 0;
	let testi.........完整代码请登录后点击上方下载按钮下载查看

网友评论0