发个游戏特效的收集网站
http://www.themysticalforestzone.com/sprites/SFX_items_tutorials/SFX.htm
如果做游戏的朋友正在为游戏特效发愁时不妨到此处看看这些特效,希望能帮到你们。。。
Wednesday, November 24th, 2010 | Permalink
发个游戏特效的收集网站
http://www.themysticalforestzone.com/sprites/SFX_items_tutorials/SFX.htm
如果做游戏的朋友正在为游戏特效发愁时不妨到此处看看这些特效,希望能帮到你们。。。
Monday, November 22nd, 2010 | Permalink
废话少说上代码
AMF3Decoder.java
package com.eunut.server.filter;
import java.io.DataInputStream;
import java.util.zip.InflaterInputStream;
import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolDecoderOutput;
import com.eunut.server.vo.RequestMessage;
import flex.messaging.io.SerializationContext;
import flex.messaging.io.amf.Amf3Input;
public class AMF3Decoder extends CumulativeProtocolDecoder
{
private final SerializationContext context = new SerializationContext();
private Amf3Input amf3in;
public AMF3Decoder()
{
}
@Override
protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception
{
long sid = session.getId();
if(in.prefixedDataAvailable(4)){
amf3in = new Amf3Input(context);
// 正常读取包头制定长度数据
int len = in.getInt();
Object message = null;
byte bytes[] = new byte[len];
in.get(bytes, 0, len);
IoBuffer tempIn = IoBuffer.wrap(bytes);
try {
amf3in.setInputStream(new InflaterInputStream(new DataInputStream(tempIn.asInputStream())));
message = amf3in.readObject();
if (message != null && (message instanceof RequestMessage)) {
out.write(message);
amf3in.close();
amf3in = null;
} else {
System.out.println(sid+":不是amf3 RequestMessage 跳出");
}
} catch (Exception e) {
System.out.println(sid+":AMF3Decoder doDecode Exception:" + e);
return false;
}finally{
tempIn.free();
tempIn = null;
bytes = null;
}
return true;
}else{
System.err.println("又粘包了!");
return false;
}
}
}
Saturday, September 4th, 2010 | Permalink
由于需要,做的这么个简单的小游戏,其实有些事情并不难,就是找个合适的解决方案。
上代码:
package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Loader; import flash.display.Sprite; import flash.errors.MemoryError; import flash.events.Event; import flash.events.KeyboardEvent; import flash.geom.Point; import flash.geom.Rectangle; import flash.net.URLRequest; import flash.text.TextField; public class ImagePuzzle extends Sprite { private var img:Loader = new Loader(); private var num:uint = 6; private var blocks:Array = new Array(num); private var currPosition:Object = {"indexX":num-1,"indexY":num-1}; private var result:TextField; public function ImagePuzzle() { img.contentLoaderInfo.addEventListener(Event.COMPLETE,cutImg); img.load(new URLRequest("16.jpg")); this.stage.addEventListener(KeyboardEvent.KEY_DOWN,keyHandle); result = new TextField(); result.text="进行中。。。"; result.height = 24; result.x = 260; addChild(result); } private function cutImg(event:Event):void{ var oldImg:Bitmap = Bitmap(img.content); var bitImgData:BitmapData = oldImg.bitmapData; var blockW:Number = bitImgData.width/num; var blockH:Number = bitImgData.height/num; oldImg.x = bitImgData.width + 20; oldImg.y = result.height; addChild(oldImg); for (var i:Number = 0;i<num;i++){ blocks[i] = new Array(num); for (var j:Number = 0;j<num;j++){ var block:BitmapData = new BitmapData(blockW,blockH, false, 0x000000); var toX:Number = blockW*j; var toY:Number = blockH*i; var blockImg:Bitmap = new Bitmap(block); if(!(i == num-1 && j == num-1)){ block.copyPixels(bitImgData, new Rectangle(toX,toY,blockW,blockH), new Point(0,0)); } blockImg.x = toX; blockImg.y = toY+result.height;; blocks[i][j] = blockImg; blockImg.name = "blockImg"+i+j; addChild(blockImg); } } randomBlock(); } private function swapBlock(temp:Object,currPosition:Object,isJudge:Boolean= true):void{ var one:Bitmap = blocks[temp.indexX][temp.indexY]; var two:Bitmap = blocks[currPosition.indexX][currPosition.indexY]; var tempX:Number = one.x; var tempY:Number = one.y; one.x = two.x; one.y = two.y; two.x = tempX; two.y = tempY; blocks[temp.indexX][temp.indexY] = two; blocks[currPosition.indexX][currPosition.indexY] = one; if(isJudge){ if(judgeWin()) result.text = "YOU WIN !!!"; }else{ if(blocks[temp.indexX][temp.indexY].name=="blockImg55"){ this.currPosition = {"indexX":temp.indexX,"indexY":[temp.indexY]}; } if(blocks[currPosition.indexX][currPosition.indexY].name=="blockImg55"){ this.currPosition = {"indexX":currPosition.indexX,"indexY":[currPosition.indexY]}; } } } private function randomBlock():void{ var temp:Number = Math.floor(Math.random()*num*num)+num*num/2; while(temp--){ swapBlock( {"indexX":Math.floor(Math.random()*num),"indexY":Math.floor(Math.random()*num)}, {"indexX":Math.floor(Math.random()*num),"indexY":Math.floor(Math.random()*num)}, false ); } } private function judgeWin():Boolean{ for(var i:uint=0;i<blocks.length;i++) for(var j:uint=0;j0){ currPosition.indexY--; } if(keyCode == 40 && currPosition.indexX>0){ currPosition.indexX--; } if(keyCode == 37 && currPosition.indexY<(num-1)){ currPosition.indexY++; } if(keyCode == 38 && currPosition.indexX<num-1){ currPosition.indexX++; } swapBlock(temp,currPosition); } } }
You are currently browsing the archives for the 游戏 category.