ç¨FlashPunkæ¥åå»ºä½ æ¸¸æçUI并ä¸å®¹æï¼å 为å®ä¸å
å«ä»»ä½UIå
件ï¼å¦æé®ææ¬æ¡çã尽管å¦æ¤ï¼è¿å¹¶éä¸ä¸ªçº¦æï¼è¿æå³çä½ å¯ä»¥é常èªç±çå°UIåæä½ æ³è¦çæ ·åãä½æ¯ä½ é¦å
è¦ç¥éå¦ä½å»åï¼è¿ä¸ªæå¦è¾
导å°æä¼ä½ å¦ä½å»å¶ä½ä¸äºç»å
¸çUIå
件ï¼å¹¶ä¸ä¸ºä½ å±ç¤ºå ç§ä¸åæ¹æ³è®©ä½ å¶ä½æ符åä½ æ¸¸æé£æ ¼çå
件ã
第ä¸æ¥ï¼å¼è®º
许å¤flashpunkç使ç¨è
å¨ä¸ºä»ä»¬ç游æå¶ä½UIæ¶é½ä¼éå°é®é¢ã没æç®åçæ¹æ³æ¥å¶ä½æé®åå
¶ä»å¯ä»¥ç¸äºä½ç¨çå
ç´ å¦ææ¬æ¡ææ£æ¥çï¼å¨FlashPunkéï¼æ²¡æButton classã
é£çèµ·æ¥ä¼¼ä¹æ¯ä¸ç§çº¦æï¼æ¯çï¼å¹¶ä¸è®¸å¤æ°æå¨å¼å§çæ¶åä¼æå°å¾æ··ä¹±ãä½æ¯è¿èåæ¯æåå çãæ¯ä¸ä¸ªæ¸¸æé½å¾åäºæä¸ä¸ªç¬ç¹çç¨æ·çé¢ï¼å®ç设计åå³äºå®çmechanicsæå®ä»¬èªèº«ç主é¢ãä½ ä¸ä¼çå°ä»»ä½ä¸æ¬¾å¥½æ¸¸æç¨é»è®¤ççªå£æé®æ¥æä½ï¼
æ以è¿ç¯æç¨å°è¦åä½ å±ç¤ºçæ¯å¨FlashPunkä¸å¦ä½ä¸ºä½ ç游æå¶ä½å±äºä½ èªå·±çUIå
ç´ ï¼ç»ä»ä»¬è¡ä¸ºï¼å¹¶å±ç¤ºä¸äºæ巧让ä»ä»¬çç»å¾é¨åæ¥æææç¨çææ¯ãä½æ¯è¦è®°ä½ï¼ä½ çæ¯ä¸ä¸ªæ¸¸æé½å°æä¸ä¸ªä¸åç¾æ¯é£æ ¼çUIï¼
ç±äºè¿ä¸ªæç¨é常çé¿ï¼å®å·²ç»è¢«åæäºå¤ä¸ªé¨åãè¿ç¬¬ä¸é¨åå°ä»ç»å¦ä½å»å¶ä½æ¯ä¸ä¸ªå
件ï¼æ²¡æeye-candy and costumizationãæ们å°å¨ä»¥åä»ç»ã
To code the example SWF with our UIï¼æ们å°ä½¿ç¨FlashPunkï¼å 为è¿æ¯ä¸ç¯FlashPunkæç¨ï¼FlashDevelopä½ä¸ºIDEãå¦æä½ è§å¾ç¨å
¶ä»çIDEæ´å 顺æï¼ä¾å¦FlashBuilderï¼ä½ ä¹å¯å·²ä½¿ç¨ï¼åªè¦å¨æ ¹æ®æç¨å¨ç»èé¨åè¿è¡è°æ´ã
对äºè¿ç¯æç¨ï¼ä½ éè¦æä¸å®FlashPunkçç¥è¯ãè¿ä¸æ¯ä¸ç¯å
³äºFlashPunkçå
¨é¢æç¨ï¼è¿æ¯FlashPunkçUIæç¨ãå¦æä½ ä¸äºè§£FlashPunkï¼ä½ å¯ä»¥å¨Activetuts+ä¸çä¸ä¸FlashPunkæç¨ç´¢å¼ï¼ä¹å¯ä»¥å¨FlashPunkçå®æ¹ç½ç«ä¸å¯»æ¾è¾
导ã
第äºæ¥ï¼æ°å»ºä¸ä¸ªé¡¹ç®
æå¼FlashDevelop ç¹å»Project-> New Projectæ¥æå¼æ°å»ºé¡¹ç®ççªå£ã
éæ©ActionScript 3 > AS3 Projectãå¨é¡¹ç®çååæ ä¸ï¼æ·»å
¥âFlashPunk UIâãå¨åå¨ä½ç½®æ ï¼éæ©ä½ æ³è¦åæ¾çæ件夹ãé»è®¤âcreate directory for projectâ为被éç¶æ并ç¹å»OKã
第ä¸æ¥ï¼ä¸è½½ææ°çFlashPunk
å»FlashPunkçå®ç½ä¸»é¡µï¼FlashPunk.netï¼ç¹å»å¯¼èªæ ä¸çDownloadæé®ãç¶åç¹å»é¡µé¢ä¸ç«¯çâDownload FlashPunkâé¾æ¥ãå®å°å¸¦ä½ 转å
¥GitHubä¸è½½é¡µé¢ãç¹å»âDownload.zipâæé®ï¼æâDownload.tar.gzâå¦æä½ éæ©è¿ç§æ ¼å¼ï¼ç¶åå°æ件ä¿åå¨ä½ ç¥éçå°æ¹ã
第åæ¥ï¼å°FlashPunkå å
¥æ们ç项ç®
ç°å¨æ们已ç»ä¸è½½äºFlashPunkï¼æ们å¿
é¡»å°å®å å
¥æ们ç项ç®ãæ们åªè¦åé常é£æ ·ç®åå°å°ânetâæ件夹ä»FlashPunk zipå¤å¶å°æ们ç项ç®ä¸çâsrcâæ件夹ã
第äºæ¥ï¼é©±å¨å¼æ
ç°å¨æ们è¦å¨æ们çæ档类ä¸åå§åFlashPunkï¼è¿æ ·æè½æ§å¶æ们ç游æï¼å°±åå¨æ¯ä¸ä¸ªFlashPunk游æä¸é£æ ·ãæ们éè¿ç¨æ档类æ©å±Engineç±»æ¥è¾¾å°ç®çï¼å¹¶åè°super æéè¦çåæ°ãæ们设å®ä¸ä¸ª550x400åç´ ççªå£ãä¸è¦å¿è®°å¨ä½ ç项ç®ä¸åå»å³é®ï¼ å¨å±æ§ä¸å°å°ºå¯¸è®¾å®ä¸º550x400åç´ ã
Package
{
import net.flashpunk.Engine;
public class Main extends Engine
{
public function Main():void
{
super(550, 400);
}
}
}
å¤å¶ä»£ç
第å
æ¥ï¼ å建Our World
ç°å¨ï¼æ们éè¦å建ä¸ä¸ªFlashPunk Worldæ¥è£
è½½æ们çå®ä½å¯¹è±¡ãæ们å°ææ¯ä¸ä¸ªUIå
件å建å¨è¿ï¼è¿æ ·æ们å¯ä»¥æµéªä»ä»¬ãå¨ä¸ä¸ªreal-worldå®ä¾ä¸ï¼æ们èåçæ¯ä¸ä¸ªç¶æé½å°å¯¹åºè¿ä¸ä¸ªä¸åçWorldï¼æ¸¸æä¹æ¯å¦æ¤ãæ以æ们å°å¨âsrcâæ件夹ä¸å建ä¸ä¸ªå
å«Worldç±»ï¼å为TestWorldçç±»ã
Package
{
import net.flashpunk.World;
public class TestWorld extends World
{
public function TestWorld()
{
super();
}
}
}
å¤å¶ä»£ç
ç¶åæ们å°åè¯æ们çEngine ç±»å»æ们çTestWorldéè½½initåè½ãä¸è¦å¿è®°å è½½ä»netãFlashpunkä¸å è½½FPç±»ï¼
override public function init():void
{
super.init();
FP.world = new TestWorld;
}
å¤å¶ä»£ç
第ä¸æ¥ï¼Buttonå®ä¾
æ们é¦å
è¦åçæ¯å»ºç«ä¸ä¸ªButtonå
件ãæ们以åè¦å»ºçæ¯ä¸ä¸ªå
件é½æ¯ä¸ä¸ªå®ä¾ï¼è¿æ¯æ们å¨FlashPunkä¸å建ä¸äºæ¾å¨Worldä¸å
件çåºæ¬æ¥éª¤ãæå¼å§ï¼æ们è¦å¨âsrcâæ件夹ä¸å建ä¸ä¸ªæ°çæ件夹ï¼ç¶å®ä¾åæ¾çææ¡çä¸äºãæ们æè¿ä¸ªæ件夹å½å为âuiâ,并ç¨æ¥åæ¾æ们ææçå
件ã
ç¶åæ们å建ä¸ä¸ªå
å«EntityçButtonç±»ãå
åå«uiï¼å 为å®å¨uiæ件夹ä¸ã
package ui
{
import net.flashpunk.Entity;
public class Button extends Entity
{
public function Button(x:Number=0, y:Number=0)
{
super(x, y);
}
}
}
å¤å¶ä»£ç
ç°å¨æ们è¦å¨æ们çworldä¸å å
¥è¿ä¸ªButtonçå®ä¾ï¼è¿æ ·æ们æè½çå°å®è¿è¡ï¼æ们å®æå®æ¶å®æ¯ä¸ä¸ªä¸å¯è§çå®ä¾ãæ以å°å®å å
¥å°æ们çTestWorldç±»ä¸ï¼ç¶åä¸è¦å¿è®°å è½½Buttonç±»ï¼ç¨å¦ä¸ä»£ç import ui.Button;
override public function begin():void
{
super.begin();
add(new Button(10, 10));
}
å¤å¶ä»£ç
温馨提示:内容为网友见解,仅供参考