2011年6月24日 星期五

Flash Actionscript Physics Engine(APE) I

這個物理引擎算時是有點老

不過基於簡單原則,這幾天開始研究起這個工具,不過由於官網上的說明真的太少了

雖然說是簡單,但也花了二天找了一下相關的資源

首先當然就是官網  http://www.cove.org/ape/

資料真是少的可憐  只有二個Demo , As Doc ,及一個簡單到不可再簡單的Tutorial

這個引擎確實是簡單的多,主要的組成

  1. 把引擎初始化
  2. 設定在畫面上的物件
  3. 設定群組並加入引擎
  4. 讓引擎不斷重繪

真的就是這幾個步驟

另外這個引擎主要的元素也不多

  1. CircleParticles
  2. RectangleParticles
  3. WheelParticles
  4. SpringConstraints   -  稍微複雜的物件即可用這個元素拼出來
  5. Grouping    - 更複雜的物件就用到這個元素
  6. Collision

即然只有二個Demo,其實其中二個demo的內容還蠻值得參考的,不過因為未提供source

只好把它decompile一下,了解過內容對於基本的物理運動要求應該是可以達到的  ^_^

以下是幾個網上找到的資源,其中需要在該這些網多翻一些其它頁面,可以更多範例

2011年6月2日 星期四

stateGroups 簡易範例

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955"
minHeight="600">

<fx:Script>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void
{
this.currentState='one';
}

protected function button2_clickHandler(event:MouseEvent):void
{
this.currentState='two';
}

protected function button3_clickHandler(event:MouseEvent):void
{
this.currentState='three';
}
]]>
</fx:Script>

<s:states>
<s:State name="one"
stateGroups="o"/>
<s:State name="two"
stateGroups="t"/>
<s:State name="three"
stateGroups="o,t"/>
</s:states>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Button x="32"
y="346"
label="Button"
click="button1_clickHandler(event)"/>
<s:Button x="106"
y="346"
label="Button"
click="button2_clickHandler(event)"/>
<s:Button x="184"
y="346"
label="Button"
click="button3_clickHandler(event)"/>
<s:BorderContainer includeIn="o"
x="32"
y="32"
width="200"
height="200"
backgroundColor="#F01010">
</s:BorderContainer>
<s:BorderContainer includeIn="t"
x="263"
y="32"
width="200"
height="200"
backgroundColor="#420BF5">
</s:BorderContainer>
</s:Application>




2011年5月8日 星期日

BOX2D Learning Resources(Different edition)

最近的工作開始接觸到 物理引擎 ,看起目前蠻多人在用的2D遊戲開發引擎
目前公司使用到的是BOX2D,這個引擎看起似乎不會太難了解
首先,先記錄幾個找到資源,後續再加上一些學習記錄

            1.For Flash:

            Box2d flash

Box2d Flash Alchemy Port   <=Ticore evaluated it,and said perfomance better

Example:

Hello Box2D

BOX2D影教學

Example:

http://www.emanueleferonato.com/category/box2d/

https://github.com/zfoley/PhysicsCannonGameSource  <= interesting similar as Angry Birds

Above example’s blog :http://plasticsturgeon.com/2011/05/box-2d-2-1a-cannon-game-part-3-the-complete-game-source/

2.For Js:

http://box2d-js.sourceforge.net/index2.html

http://net.tutsplus.com/tutorials/html-css-techniques/build-your-first-game-with-html5/

3.For Java

http://www.jbox2d.org/

4.Cocos2d with box2d(cocos2d is  iphone framework)

http://www.raywenderlich.com/457/intro-to-box2d-with-cocos2d-tutorial-bouncing-balls

http://iphonedev.net/2009/07/12/cocos2d-example-box2d/

http://www.cocos2d-iphone.org/wiki/doku.php/   when install cocos2d in xcode,we can find a template with box2d

5.Native

http://www.box2d.org

2011年3月8日 星期二

Progression4-0-Installation(Win7 CS5 Extra.)

上去聽完了 AS讀書會後,感覺用Progression來做網站真的是一個不錯的選擇

去之前就至Progression的網站下載了extension,

安裝後打開Flash CS5居然啥都看不到

聽完Gray的介紹才知原來是語系的問題,由Gray網中找到奶綠的安裝說明


奶綠用的是CS3、CS4,個人是使用CS5


CS5的目錄是在 Users/{User Profile}/AppData/Local/Adobe/Flash CS5


筆者安裝時是用英文版在 這個目錄下有 en_US、ja_JP、zh_TW三個目錄






直接把ja_JP下的Configuration目錄直接複製到en_US(依次類推)

再次打開Flash CS5,即可在Windows=>Other Panels 看到Progression帶日文的二個選項了

筆著只是做小筆記For Win7(CS5),主要還是參考Gray的筆記應該會較為詳細

2011年2月14日 星期一

Flex i18n

不小心被我誤刪了
有機會再來補

2010年11月10日 星期三

Simple Canvas Demo

Below is js code:

$(function(){
var selectColor = 'red';
var canvas = document.getElementById('canvas')
var ctx = canvas.getContext('2d');
$('#canvas').mousedown(function(e){


ctx.strokeStyle = selectColor;
ctx.beginPath();
ctx.moveTo(e.clientX, e.clientY);
ctx.lineTo(e.clientX-1, e.clientY-1);
var px,py;
$('#canvas').bind('mousemove',function(e){

var x = px = e.clientX;
var y = py = e.clientY;

ctx.lineTo(x, y);
ctx.lineTo(x+2, y+2);
ctx.stroke();

$('#canvas').mouseup(function(e){
$('#canvas').unbind('mousemove');
ctx.lineTo(e.clientX, e.clientY);
ctx.lineTo(e.clientX+2, e.clientY+2);
});
});
})

$(document).mouseup(function(){
$('#canvas').unbind('mousemove');
});

var colors = ['#0000FF','#FFFF00','#00FF00','#FF0000','#FF91FE','#BE6100','#BCBE00','#5DBE00','#00BCBE'];
for(var i=0;i<10;i++){ class="tool" id="+i+">');
$('#'+i).css({'background-color':colors[i%colors.length]});
$('#'+i).click(function(){
$(this).addClass('toolactive');
selectColor = $(this).css('background-color');
}).mouseup(function(){
$(this).removeClass('toolactive');
});
}

$('#canvas').mouseover(function(e){
//tools.detect(e);
}).mousemove(function(e){
tools.detect(e);
}).mouseout(function(e){
$('#tools').mousemove(function(){
$('#tools').css({opacity:1});
}).mouseout(function(){
tools.hide();
});
tools.hide();
});
});




var tools ={
detect:function(e){
if(e.pageY>400){
this.show();
}else{
this.hide();
}
},
show:function(){
$('#tools').stop().animate({opacity:1},'slow',function(){
});
},
hide:function(){
$('#tools').stop().animate({opacity:0},'slow',function(){
});
}
}

Below is css code:

#canvas{
border:solid;
z-index:100;
}

.tool{
float:left;
padding:5px;
margin:5px;
width:50px;
height:30px;
background-color:#0000FF;
}

.toolactive{
background-color:#FF0000;
}

#tools{
background-color:#DDDDDD;
position:absolute;
bottom:25%;
left:15%;
float:left;
width:360px;
height:100px;
border:solid;
opacity:0;
}

Below is html code:






























Your browser should support canvas tag.
Demo link

2010年9月29日 星期三

Realize offline database store image file

  1. We could use convas.toDataURL() function to get base64 character,and store those data into sqllite data base
  2. Retrieve the hexadecimal data and pass those on the img tag i.e
  3. convas.toDataURL() will get as below data:


Reference as below:
1. https://developer.mozilla.org/en/Canvas_tutorial/Drawing_shapes
2. http://en.wikipedia.org/wiki/Data_URI_scheme

2010年8月26日 星期四

Location of flashlog.txt

The output of trace statements is logged to flashlog.txt in the debug version of Flash
Following is the location of flash player log file (flashlog.txt) on various operating systems.

  • Windows Vista : C:\Users\{user-name}\AppData\Roaming\Macromedia\Flash Player\Logs
  • Windows XP : C:\Documents and Settings\{user-name}\Application Data\Macromedia\Flash Player\Logs
  • Linux : /home/{user-name}/.macromedia/Flash_Player/Logs/
  • Mac : /Users/{user-name}/Library/Preferences/Macromedia/Flash Player/Logs/

2010年8月10日 星期二

How to use Chrome console


if(!window.console)
console = {};
console.log = console.log || function(){};
console.warn = console.warn || function(){};
console.error = console.error || function(){};
console.info = console.info || function(){};

console.log('--log--');
console.error('--error--');
console.info('--info--');
console.warn('--warn--');

2010年6月30日 星期三

flashplayer debug mode on firefox got crash error (Firefox上flashplayer 一直當機)

最近使用Firefox在寫Flex在debug mode,正在專注要看varible的變化
結果就flash就當機了
google了一下 找到T客邦的這篇文章

外掛當機,本尊沒事的Firefox 3.6.4來了
總結了一下
我做的小修改
主要就是在 firefox 叫出 about:config 後 篩選條件 dom.ipc.plugins.enabled
其中 dom.ipc.plugins.enabled.npswf32.dll; 應該是關連 flashplayer的把它關掉就不會再當機啦
T客邦中另外提到可以下 about:crashes 看一下當機紀錄,還看不是很懂
再者就是 http://www.mozilla.com/en-US/plugincheck/ 可以 check一下firefox裝了哪些plugin

2011/05/06 updated

In 4.0.1 version cant’ got above option
need to search below attribute
dom.ipc.plugins.timeoutSecs
and set the value to –1
 
2011/07/20 updated
In 5.0 version occur this error
發現容易停止回應的程式碼(Script)  [In engilish is unresponsive script warning]
need to setup another attribute
dom.max_script_run_time
and set the value to 20
if can’t find out this attribute ,create new attribute as above

reference link:

http://kb.mozillazine.org/Unresponsive_Script_Warning   <= offcial(english)

http://tw.knowledge.yahoo.com/question/question?qid=1608040905384 <= yahoo+(chinese)

 



2010年6月9日 星期三

Flex Load Image with ProgressBar







import mx.collections.ArrayCollection;
[Bindable]
private var datas:ArrayCollection= new ArrayCollection([{label:'Flex',data:'http://mixmatters.com/hot/2008/images/DJ_Flex-Te_Quiero.jpg'},
{label:'Apple',data:'http://www.teksource.com.tw/Quotation_TEK/images/product/APPLE.jpg'},
{label:'Google',data:'http://140.136.240.106/98/images/google_logo.jpg'},
{label:'Nokia',data:'http://www.blogcdn.com/www.engadgetmobile.com/media/2008/11/nokia-crystal-ball.jpg'}]);
]]>

source="http://mixmatters.com/hot/2008/images/DJ_Flex-Te_Quiero.jpg"
x="{this.list.x + this.list.width}"
y="10"
horizontalAlign="center"
open="progressBar.visible = true"
complete="progressBar.visible = false"
completeEffect="Fade"/>
x="{this.list.x + this.list.width}"
y="10"
source="{image}"
visible="false"
showEffect="Fade"
hideEffect="Fade"/>


image.source = list.selectedItem.data;
]]>




Flex - Slide Menu





layout="absolute"
height="100%" width="100%">




















toState="over1">
target="{this.c1}"
duration="2000"/>

toState="over2">
target="{this.c2}"
duration="2000"/>

toState="over3">
target="{this.c3}"
duration="2000"/>

toState="over4">
target="{this.c4}"
duration="2000"/>

toState="over1-1">
target="{this.c1}"
duration="1000"/>

toState="over2-2">
target="{this.c2}"
duration="1000"/>

toState="over3-3">
target="{this.c3}"
duration="1000"/>

toState="over4-4">
target="{this.c4}"
duration="1000"/>


x="{this.canvas1.x}"
y="{this.canvas1.y}"
width="200"
height="55">


y="23"
width="200"
height="55"
id="canvas1"
mouseOut="this.currentState='over1-1'"
mouseOver="this.currentState = 'over1'">


x="{this.canvas2.x}"
y="{this.canvas2.y}"
width="200"
height="55">


y="96"
width="200"
height="55"
id="canvas2"
mouseOut="this.currentState='over2-2'"
mouseOver="this.currentState = 'over2'">


x="{this.canvas3.x}"
y="{this.canvas3.y}"
width="200"
height="55">


y="168"
width="200"
height="55"
id="canvas3"
mouseOut="this.currentState='over3-3'"
mouseOver="this.currentState = 'over3'">


x="{this.canvas4.x}"
y="{this.canvas4.y}"
width="200"
height="55">


y="242"
width="200"
height="55"
id="canvas4"
mouseOut="this.currentState='over4-4'"
mouseOver="this.currentState = 'over4'">



2010年6月2日 星期三

2010年4月6日 星期二

Flex3 搭配amfphp










2009年7月7日 星期二

2009年7月3日 星期五

Radio Head Japan



超讚分鏡影片
http://www.wowow.co.jp/music/radiohead/special/

2009年5月17日 星期日

使用Flex Code Generator開發Flex+PHP

為加速開發Flex+PHP,於是使用了
FCG : a Flex Code Generator
  • 過往在Java的經驗,寫ORM的model及DAO是最沒價值又費時間的,所以會較依賴generator
  • 此程式在產生對應java的as model時,會有型態無法直接轉換的問題 e.g.java中 BigDecimal 轉到as仍是BigDecimal但as裡沒有BigDecimal型態,不過己可減少蠻多這種重覆又沒義意的工作了
建立過程會分二個階段,我們先來介紹過PHP的部份
  1. 首先直接在該網站使用線上安裝(會直接偵測是否有安裝AIR)
  2. 裝好後先在MySQL建立好了幾張table,再將script export出來
  3. 啟動FCG後在【Main Package Name】輸入自己的full package name <= 這個階段可暫不輸入
  4. 接著選擇【Project Type】 選擇【PHP】 => 【Start Project】
  5. 【Import SQL】 選擇己export出來的table script <= 只可包含Create Table的script
  6. Finish後即可出現即可出現所有的VO及DAO PHP程式
  7. 內容中有一個header.php ,請自行建立所需資料庫相關資訊
待續.......

2009年5月14日 星期四

二個共同寫一支程式(同時間)

XP(Extreme Programming) 提到的 配對編碼(Pair Programming)
eclipse plug-in Eclipse Communication Framework Project
乎似真能做到二個同共寫一支程式,哪天也來試試二個共同寫一支程式帶來的效益
建議用HD看會比較清楚

Cola: Real-Time Shared Editing from Mustafa K. Isik on Vimeo.

2009年5月10日 星期日

Creat second tomcat server using same Tomcat














































































































投影片 320

2009年5月2日 星期六

Android 手機應用程式設計入門by gasolin

    實作上發現書中問題點筆記
    十四章加入選單
  1. 加上後面這段應可讓真沒寫過java的人更容易入手需覆寫實作Activity的method時可由eclipse 原始碼中【滑鼠右鍵】=>【source】=>【override/implement methods....】即可在選單上選擇找到欲覆寫/實作的method,不用去打這個字,避免打錯
  2. 加了二個function(public boolean onCreateOptionsMenu(Menu menu)、public boolean onOptionsItemSelected(MenuItem item))後在emulator上是需要按了 menu後才會出現所加的menu,以上應該也說明一下
  3. 圖示放到 res/drawable 裡的圖檔檔名除了只接受英文字母、數字、或底線 ................我們看到console 上出現res\drawable\Delete.png: Invalid file name: must contain only [a-z0-9_.],所以對己定義的RegExp為檔案不接受大寫字母(所使用版本為 android-sdk-windows-1.1_r1)ps.1.5版也是。