|
|
???jQuery+DIV????(??????)
<!--??? - heyiyong - qq - 290248126 ???jQuery+DIV???????????? -->
<!DOCTYPE html>
<html>
<head>
<title>demo</title>
<style type="text/css">
* {
padding: 0;
margin: 0;
}
.mao {
background: #ff6e06;
position: fixed;
width: 50px;
height: 50px;
font-size: 25px;
line-height: 50px;
text-align: center;
z-index: 100;
}
.laoshu {
background: #21ff00;
position: fixed;
top: 300px;
left: 500px;
width: 100px;
height: 100px;
font-size: 25px;
text-align: center;
line-height: 100px;
}
.result {
height: 80px;
width: 300px;
background: #ffafb9;
color: #219aff;
font-weight: bolder;
font-size: 30px;
text-align: center;
margin: 10px auto;
line-height: 80px;
}
</style>
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<script type="text/javascript">
var maoX = 0;//??????
var maoY = 0;//??????
var laoshuX = 500;//??????
var laoshuY = 300;//??????
/**
* ????????
*/
$(document).keydown(function (event) {
if (event.which === 37) {
maoY = maoY - 10;
$("#mao").css("left", maoY + "px");
} else if (event.which === 38) {
maoX = maoX - 10;
$("#mao").css("top", maoX + "px");
} else if (event.which === 39) {
maoY = maoY + 10;
$("#mao").css("left", maoY + "px");
} else if (event.which === 40) {
maoX = maoX + 10;
$("#mao").css("top", maoX + "px");
}
});
function pengzhuangCheck() {
//???????????????????????
var maoOffset = $("#mao").offset();
var maoWidth = parseInt($("#mao").css("width").replace("px", "")); var maoHeight = parseInt($("#mao").css("height").replace("px", "")); //???????????????????????? var laoshuOffset = $("#laoshu").offset();
var laoshuHeight = parseInt($("#laoshu").css("height").replace("px", "")); var laoshuWidth = parseInt($("#laoshu").css("width").replace("px", "")); //????????bool?
var leftBool;
var topBool;
//??????
if (maoOffset.left > laoshuOffset.left) {
leftBool = maoOffset.left - laoshuOffset.left - laoshuWidth < 0;
// console.log("??????????"+leftBool); } else {
leftBool = laoshuOffset.left - maoOffset.left - maoWidth < 0; // console.log("?????????? "+leftBool); }
//??????
if (maoOffset.top > laoshuOffset.top) {
topBool = maoOffset.top - laoshuOffset.top - laoshuHeight < 0; // console.log("??????????"+topBool); } else {
topBool = laoshuOffset.top - maoOffset.top - maoHeight < 0; // console.log("????? ?????"+topBool); }
//??????????????
if (leftBool && topBool) {
// alert("??????");
$("div[class=result]").html("??????");
} else {
$("div[class=result]").html("????????");
}
}
/**
* ??????
*/
function mouseAutoMove() {
var num = Math.round(Math.random() * 10) % 4;
switch (num) {
case 0 ://?
laoshuY -= 5;
$("#laoshu").css("top", laoshuY + "px");
break;
case 1 ://?
laoshuY += 5;
$("#laoshu").css("top", laoshuY + "px");
break;
case 2 ://?
laoshuX -= 5;
$("#laoshu").css("left", laoshuX + "px");
break;
case 3 ://?
laoshuX += 5;
$("#laoshu").css("left", laoshuX + "px");
break;
}
//????????????????? pengzhuangCheck();
}
//??????????
$(function () {
//??????
setInterval("mouseAutoMove()", 80);})
</script>
</head>
<body>
<div id="mao" class="mao">
?
</div>
<div id="laoshu" class="laoshu">
??
</div>
<div class="result"></div>
</body>
</html>
???????????
????
???????????
Requirement Analysis Specification
? ? ?????? ? ?? ? ??
?????
1
??
??? ??1 1?1 ?????.3 1?2 ????..3 1?3 ????3 ??? ????.3 2?1 ???3 2?1?1 ???..3 2?1?2 ???.3 2?2 ????3 2?2?1 ???3 2?2?2 ??-????3 2?2?3 ??-????...3 2?3 ????..4 2?4 ????.4 ??? ????5 3?1 ????.5 3?2 ????.5 3?3 ????.5 ??? ????.5 4?1 ??????..5 4?2 ????..5 ??? ????.6 5?1 ????...6 5?1 ?????...6 ??? ?????????.6 6?1 ????...6 6?2 ????...6
2
??? ?? 1?1 ?????
?????????????????????????
??????????????????????????????????????????????????????opengl?????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????
1?2 ????
???????Windows XP?? 1?3 ????
?????????????????? ??? ???? 2?1 ??? ???
2?1?1 ??? ???
2?1?2 ??? ??? 2?2 ???? 2?
2?2?2 ??-????
3
2?2?3 ??-????
???????
2?3 ???? 2?4 ????
4
??? ???? 3?1 ????
? ???????????????????????????????????
????????????????????????????????????????
???????
3?2 ????
1??????????????? 2)??????????? 3???????????? 4?????????? 3?3 ????
1)?????????
2)????????????????????
??? ????
????????????????????????????????
???????????????????????????????????????????????????????????????
4?1 ??????
1.?????
???3D???????????
2.?????
?????????????????????
5
?????Actionscript 3.0?????????
??Actionscript 3.0?????flash????
???????actionscript3.0??hitTestObject()??????????????flash???hitTestObject()???flash???????????????????????????????????flash???
???????? ?? ???? ????
The Game Design of flash game about hitTest
Based on Actionscript3.0
Abstract?In the paper,it implements a simple flash game about hitTest using the hitTestObject method in actionscript3. hitTestObject method is usually used in flash game design, Running speed.using it we can design many action and hittest flash game.
Keyword: hitTest Action game design network game
0??
???????????????????????????Actionscript 3.0??????????????????Actionscript 3.0???????????????QZone???????????????Actionscript 3.0????????????Actionscript 3.0
[1]???????????????????
1 ??????
1.1 ????
ActionScript 3.0???????????? (DOM) ?3?????????????
[2]?????????ActionScript???????????????????
??????????????????????????????????????????????????????????????????????????
[3]??????????????????????????
????????????????????????????
function eventResponse(eventObject:EventType):void
{
// ???????????????
}
eventTarget.addEventListener(EventType.EVENT_NAME, eventResponse);
??????????????????????????????????????????????????addEventListener()???????????????????????????????????????????????????????????????????????????????????????????????????????
1.2 hitTestObject()??
Actionscript3.0??hitTestObject()?????????(???????)????????????????????????true????false??????????????
????????
[5]?????????????????????
if(mc_instance1.hitTestObject(mc_instance2)){
text1.text="????????";
//?????
} [4]
2 ????
????????????????????????????????????????????????????????????????(??20?)??????????????????????(??20?)????????????(??20?)?????
[6]??
3????
???????????????????(?Apple,Strawberry,Pear,Banana,Orange),???????????(?basket_mc)?????????ActionScript????????????????????????????????????(?basket_mc)?????
[7]???????????????
import flash.events.Event;
import flash.display.MovieClip;
var fruitArray:Array=new Array(Apple,Strawberry,Pear,Banana,Orange);
var fruitsOnstage:Array=new Array();
var fruitsCollected:int=0;
var fruitsLost:int=0;
for(var i:int=0;i<20;i++){
var pickFruit=fruitArray[int(Math.random()*fruitArray.length)]
var fruit:MovieClip=new pickFruit();
addChild(fruit);
fruit.x=Math.random()*stage.stageWidth;
fruit.y=Math.random()*-500;
fruit.speed=Math.random()*15+5;
fruitsOnstage.push(fruit);
}
basket_mc.addEventListener(MouseEvent.MOUSE_DOWN,dragBasket);
stage.addEventListener(MouseEvent.MOUSE_UP,dragStop);
function dragBasket(e:Event):void{
basket_mc.startDrag();
}
function dragStop(e:Event){
basket_mc.stopDrag();
}
stage.addEventListener(Event.ENTER_FRAME,catchFruit);
function catchFruit(e:Event):void{
for(var i:int=fruitsOnstage.length-1;i>-1;i--)
{
var currentFruit:MovieClip=fruitsOnstage[i];
currentFruit.y+=currentFruit.speed;
if(currentFruit.y>stage.stageHeight-currentFruit.height){
currentFruit.y=0-currentFruit.height;
fruitsLost++;
field2_txt.text="Total Fruit Lost: "+fruitsLost;
}
if(currentFruit.hitTestObject(basket_mc)){
fruitsCollected++;
removeChild(currentFruit);
fruitsOnstage.splice(i,1);
field1_txt.text="Total Fruit Collected:"+fruitsCollected;
if(fruitsCollected>=20){
basket_mc.gotoAndStop(20);
} else if(fruitsCollected>15){
basket_mc.gotoAndStop(15);
} else if(fruitsCollected>10){
basket_mc.gotoAndStop(10);
} else if(fruitsCollected>5){
basket_mc.gotoAndStop(5);
}
}
if(fruitsOnstage.length<=0){
field1_txt.text="You win! You have collected enough fruit for dinner."; field2_txt.text="";
stage.removeEventListener(Event.ENTER_FRAME,catchFruit);
}
if(fruitsLost>=20){
field1_txt.text="Sorry! You have lost too much fruit!";
field2_txt.text="";
for(var j:int=fruitsOnstage.length-1;j>-1;j--){
currentFruit=fruitsOnstage[j];
removeChild(currentFruit);
fruitsOnstage.splice(j,1);
}
}
}
}
????????1???
?1 ???????
4??
hitTestObject()???actionscript3.0?????????????????????????????Flash???
????:
[1]???,???.Flash cs4???????[M].??????????.2009.09
[2]???,???.Adobe Flash CS4?????????????[M].??????????.2011.06.
[3]Keith Peters(?),???,????.Flash ActionScript 3.0??????[M].??????????.2010.01.
[4]???.ActionScript 3.0??????[M].??????????.2009.09.
[5]???.Flash?????ActionScript 3.0??????[M].??????????.2009.10.
[6]???,??,???.Flash ActionScript 3.0??????[M].??????????.2008.06
[7]Adobe??(?),???(?).Adobe Flash CS5 ActionScript 3.0???????[M].??????????.2010.11
?iOS,Game???????????????????
?????http://www.850500.com/news/70770.html
?????,??! |
|