2010年12月26日 星期日

Android新書介紹

Building Android Apps With HTML, CSS, and JavaScript

作者:Stark, Jonathan

出版社:Oreilly & Associates Inc
出版日期:2010年09月27日
ISBN:9781449383268


擺脫Native Apps,從Web Apps觀點介紹Android Apps

2010年12月19日 星期日

2010年11月29日 星期一

新書介紹

Professional Android 2 Application Development

作者:Meier, Reto
出版社:John Wiley & Sons Inc
出版日期:2010年03月01日
ISBN:9780470565520

http://www.amazon.com/Professional-Android-Application-Development-Programmer/dp/0470565527#reader_0470565527

2010年11月10日 星期三

Google I/O 2009 - Writing Real-Time Games for Android - 迴響

個人覺得圖形處理與thread分工是關鍵
圖形處理
thread分工

2010年10月17日 星期日

2010年10月11日 星期一

Android程式設計 (十八) 使用SQLite (3)

SQLite Database Browser
是一套具備圖形化介面的SQLite資料庫管理自由軟體工具,提供SQLite資料庫管理功能,網址:http://sqlitebrowser.sourceforge.net/
下圖為SQLite Database Browser工具列按鈕,包括資料檔作業、資料表作業及檢視SQL Log。
建立資料表
開啟資料檔後,點擊工具列中的「建立資料表」按鈕。在「Table name:」欄設定資料表名稱。
建立資料欄
在Create Table對話視窗中的「Define fileds:」作業區中點選「Add」按鈕,在「Field name:」欄設定欄位名稱,並由「Filed type:」選擇資料型別,共有四種資料型別可供選擇。
修改資料表
點擊工具列中的「修改資料表」按鈕,之後選擇要修改的資料表名稱。
檢視/修改記錄
切換到Browse Data頁籤,從Table下拉式清單中選擇資料表名稱。雙擊資料即可修改資料內容;點擊「New Record」按鈕新增記錄,點擊「Delete Record」按鈕刪除記錄。
測試SQL指令
切換到Execute SQL頁籤,從Table下拉式清單中選擇資料表名稱。

2010年10月6日 星期三

Android程式設計 (十七) 使用SQLite (2)

建立索引
當資料表儲存的記錄筆數變大時,會影響資料庫作業效能,我們可建立索引來加快速度。例如:
create index idxname on address (name);
意思是針對address資料表的name資料欄,建立一個名叫idxname的索引。一旦建立了索引,sqlite3在針對該欄位查詢作業時,就會自動使用該索引。
查詢資料庫的schema
SQLite資料庫schema是特別存於一個名為sqlite_master的系統資料表,我們可利用"SELECT"指令來查詢,例如:
sqlite> select * from sqlite_master;
table|address|address|2|CREATE TABLE address(name, email, tel)
index|idxname|address|3|CREATE INDEX idxname on address (name)
sqlite>
列出資料庫中的資料表,利用 ".tables":
sqlite> .tables
address
sqlite>
.schema指令顯示原先建立資料表與索引的指令,可以用於重建目前的資料庫用:
sqlite> .schema
CREATE TABLE address(name, email, tel);
CREATE INDEX idxname on address (name);
sqlite>
設定輸出格式
SQLite支援提供8種不同的查詢的結果格式輸出 (csv、column、html、insert、line、tabs、tcl),說明如下:
csv       逐列顯示記錄內容,並以逗號區隔資料欄
column 以多欄方式逐列顯示記錄內容,欄位寬度由.width指令設定
html     HTML表格標籤碼
insert   SQL insert指令碼
line      每列顯示一個欄位資料,格式:欄位名稱=欄位值
list       逐列顯示記錄內容,以'|'符號區隔資料欄
tabs     逐列顯示記錄內容,以tab定位鍵區隔資料欄
tcl       逐列顯示記錄內容,欄位資料以字串方式呈現並以空白鍵區隔
預設是以list格式顯示,我們可以利用".mode"指令來改變輸出格式。
sqlite> .mode csv
我們也可以利用".separator"指令來更換分隔符號,例如:
sqlite> .separator " / "
shell命令列操作SQLite
我們也可在shell命令列直接執行SQLite命令,例如:
D:\SQLite> sqlite3 demo.db "insert into address values('elian', 'elian@email.net', '4444');"
D:\SQLite> sqlite3 demo.db "select * from address;"
資料庫備份
.dump指令可以為資料庫建立標準的SQL資料庫備份,例如:
D:\SQLite>sqlite3 demo.db ".dump" > demo.sql

2010年10月5日 星期二

Android程式設計 (十六) 使用SQLite (1)

SQLite是一種專為嵌入式系統設計的關聯式資料庫,支援標準的SQL-92作業,具備簡潔、佔用系統資源小等優點。此外SQLite的資料庫是以單一檔案的形式儲存;使用時,只要在編譯程式的時候將程式庫一起編譯就可以了,不需要另外安裝資料庫伺服器軟體,所以要複製資料庫或移植到其它電腦都相當容易。
SQLite官網可下載SQLite程式,包括Mac、Linux及Windows版本,網址:http://www.sqlite.org/download.html
SQLite基本操作
所有的SQL指令都是以分號(;)結尾的。如果遇到兩個減號(--)則代表註解,SQLite會略過去。
建立資料庫檔案
假設我們要建立一個名為demo.db的資料庫,只要在命令列鍵入sqlite3 demo.db。如果目錄下沒有db_name這個資料庫,即會建立db_name資料庫,並進入SQLite作業模式;此時,命令列提示會變成sqlite>
D:\SQLite> sqlite3 demo.db
建立資料表
sqlite> create table address(name, email, tel);
上述指令建立了一個名叫address的資料表,裡面有name、email及tel三個資料欄。
加入一筆資料
sqlite> insert into address values ('tina', 'tina@email.net', '1111');
sqlite> insert into address values ('tony', 'tony@email.net', '2222');
sqlite> insert into address values ('mike', 'mike@email.net', '4444');
如果該欄位沒有資料,我們可以填NULL。
查詢資料
sqlite> select * from address where name = 'tina';
sqlite> select * from address limit 2;
sqlite> select count(*) from address;
更改資料
sqlite> update address set tel = '3333' where name = 'mike';

2010年9月28日 星期二

體感遊戲, 微軟Kinect是怎麼做到的?

今天E3展,Microsoft正式推出了體感裝置 - Kinect,話題持續燃燒。Kinect for Xbox 360 將於 11 月 19 日在台上市,同時將有 15 款 Kinect 專屬遊戲同步推出,消費者可單獨預購 Kinect 感應器(內附《Kinect 大冒險》遊戲),估計零售價新台幣 5,490 元;或購買「Xbox 360 4GB 主機 + Kinect 感應器 +《Kinect 大冒險》遊戲同捆組」,估計零售價為新台幣 10,360 元。
Kinect一次可擷取三種訊號,分別是彩色影像、3D深度影像、以及聲音訊號。Kinect機身上有3顆鏡頭,中間的鏡頭是一般常見的RGB彩色攝影機,左右兩邊鏡頭則分別為紅外線發射器和紅外線CMOS攝影機所構成的3D深度感應器,Kinect主要就是靠3D深度感應器偵測玩家的動作。
T客邦有篇專文介紹Kinect技術,推薦給大家
http://www.techbang.com.tw/posts/2936-get-to-know-how-it-works-kinect

2010年9月14日 星期二

Android手機作業系統2014年挑戰霸主地位

國際研究暨顧問機構Gartner預測,2010年,Symbian和Android在手機作業系統市場上的占有率分別可達40.1%和17.7%,Android的市占率將持續上升,Symbian反之下降。
不過,Symbian和Android仍會主宰全球手機作業系統市場,到2014年,兩大作業系統合計將占整體手機作業系統銷售的59.8%。
目前Symbian因Nokia的高銷售量而仍保持市場的領導地位。但由於許多手機製造大廠將於今年下半年投入更多預算於開發Android裝置,有助於Android在2010年超越RIM成為北美第一的作業系統。另外,Windows手機的排名到2014年將被MeeGo超越,退為第六大手機作業系統。
資料來源: 聯合理財網
http://udn.com/NEWS/FINANCE/BREAKINGNEWS6/5842144.shtml

2010年8月17日 星期二

教師赴公民營機構研習 - 多平台遊戲軟體引擎技術之剖析與應用

本次研習內容非常豐富,兼顧理論與實務,內容包括產業脈動、3D遊戲引擎技術與應用、產學合作交流座談及企業參訪,對往後開授相關課程或媒合產學合作或學生實務專題有相當大的助益。

網要如下:
1. 樂陞科技股份有限公司產品介紹/全球化營運介紹
2. 遊戲軟體引擎技術-30年來的天蠶變
3. 如假似真之3D引擎技術大揭密
4. 3D引擎技術之應用實例
5. 無遠弗屆之網路引擎技術大揭密
6. 網路引擎技術之應用實例
7. 扮演幕後功臣之遊戲開發輔助工具
8. 遊戲開發輔助工具之應用實例
9. 產學交流座談:發掘產學合作機會
10. 企業參訪-樂陞科技

樂陞科技
http://www.xpec.com.tw/

2010年8月1日 星期日

Android程式設計 (十五) 使用SharedPreferences

偏好設定(SharedPreferences)提供一個簡易的方式來儲存應用程式的設定值,方便下次應用程式被啟動時,載入偏好設定,讓應用程式自動回復到前一次設定值。此外,也可與同一套件之應用程式共享。
要使用SharedPreferences功能,應用程式需要匯入以下類別。
import android.content.SharedPreferences;
儲存偏好設定
Preference是以name-value pair方式儲存應用程式狀態,通常我們會在應用程式的onPause()方法中進行偏好設定儲存作業。首先透過getSharedPreferences()方法取得指定偏好設定檔:
public SharedPreferences getSharedPreferences (String name, int mode)
其中name為偏好設定檔名稱;mode則是偏好設定檔作業模式,MODE_PRIVATE (0)表示應用程式專用;MODE_WORLD_WRITEABLE (1)表示可與套件之其它應用程式共用。
接下來就可透過SharedPreferences.Editor編輯介面來更新偏好設定內容。這項作業必須先使用edit()方法取得SharedPreferences.Editor編輯介面,再使用putBoolean()putFloat()putInt()putLong()putString()方法來分別寫入布林資料、浮點數資料、整數資料、長整數資料及字串資料到偏好設定檔中。
    public abstract SharedPreferences.Editor putBoolean (String key, boolean value)
    public abstract SharedPreferences.Editor putFloat (String key, float value)
    public abstract SharedPreferences.Editor putInt (String key, int value)
    public abstract SharedPreferences.Editor putLong (String key, long value)
    public abstract SharedPreferences.Editor putString (String key, String value)
在此key表示偏好設定檔中的資料名稱,value則是資料值。有一點要注意,這些偏好設定值並不會立即更新,而是等到執行commit()方法後才會寫回偏好設定檔。
Date date = new Date (System.currentTimeMillis());
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    SharedPreferences settings = getSharedPreferences ("PREF_DEMO", 0);
    SharedPreferences.Editor PE = settings.edit();
    PE.putString("LAUNCH_DATE", date.toString());
    PE.putInt("LAUNCH_COUNT", count+1);
    PE.commit();
}
讀取偏好設定
要讀取偏好設定內容時,同樣先透過getSharedPreferences()方法取得指定偏好設定檔,之後再使用getBoolean()getFloat()getInt()getLong()getString()方法來分別讀取偏好設定中的布林資料、浮點數資料、整數資料、長整數資料及字串資料。
    boolean getBoolean (String key, boolean defValue)
    float getFloat (String key, float defValue)
    int getInt (String key, int defValue)
    long getLong (String key, long defValue)
    String getString (String key, String defValue)
在此key表示偏好設定檔中的資料名稱,defValue則是資料預設值。下面程式碼在應用程式一開始取回偏好設定值。
  int count=1;
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    SharedPreferences settings = getSharedPreferences("PREF_DEMO", 0);
    String LastDate = settings.getString("LAUNCH_DATE", "2010-01-01");
    count = settings.getInt("LAUNCH_COUNT", 1);
    view_date = (TextView) findViewById (R.id.txtDATE);
    view_count = (TextView) findViewById (R.id.txtCOUNT);
    view_date.setText ("Last launched: " + LastDate );
    view_count.setText ("Launched times: "+ count);
}

2010年7月23日 星期五

Best of E3 2010 Awards - Best Software Lineup

入選 (Nominees):
PC
PlayStation 3
Nintendo DS
Nintendo Wii
Xbox 360
獲獎 (Winner):
PlayStation 3

Best of E3 2010 Awards - Best Music Game

入選 (Nominees):
Ubisoft發行的Child of Eden / PlayStation 3, Xbox 360
Hamonix發行的Dance Central / Xbox 360
Activision發行的DJ Hero 2 / PlayStation 3, Xbox 360, Wii
Activision發行的Guitar Hero: Warriors of Rock / PlayStation 3, Xbox 360, Wii
Hamonix發行的Rock Band 3 / PlayStation 3, Xbox 360, Wii
獲獎 (Winner):
Hamonix發行的Rock Band 3 / PlayStation 3, Xbox 360, Wii

Best of E3 2010 Awards - Best RPG

入選 (Nominees):
Nintendo發行的Dragon Quest IX / Nintendo DS
Microsoft發行的Fable III / PC, Xbox 360
Bethesda發行的Fallout: New Vegas / PC, PlayStation 3, Xbox 360
LucasArts發行的Star Wars: The Old Republic / PC
Atari發行的The Witcher 2: Assassins of Kings / PC
獲獎 (Winner):
LucasArts發行的Star Wars: The Old Republic / PC

2010年7月22日 星期四

Best of E3 2010 Awards - Best Platformer

入選 (Nominees):
Disney發行的Disney Epic Mickey / Wii
Nintendo發行的Donkey Kong Country Returns / Wii
Nintendo發行的Kirby's Epic Yarn / Wii
SCEA發行的Little Big Planet 2 / PlayStation 3
Sega發行的Sonic Colors / Wii
獲獎 (Winner):
Nintendo發行的Kirby's Epic Yarn / Wii

Best of E3 2010 Awards - Best Sports Game

入選 (Nominees):
Electronic Arts發行的FIFA 11 / PlayStation 3, Xbox 360
Electronic Arts發行的Madden NFL 11 / PlayStation 3, Xbox 360
Electronic Arts發行的NCAA Football 11 / PlayStation 3, Xbox 360
Electronic Arts發行的NBA Jam / Wii
Electronic Arts發行的NHL 11 / PlayStation 3, Xbox 360
獲獎 (Winner):
Electronic Arts發行的Madden NFL 11 / PlayStation 3, Xbox 360

Best of E3 2010 Awards - Best Action/Adventure

入選 (Nominees):
Ubisoft發行的Assassin's Creed: Brotherhood / PC, PlayStation 3, Xbox 360
Konami發行的Castlevania: Lords of Shadow /  PlayStation 3, Xbox 360
SCEA發行的God od War: Ghost of Sparta / PSP
Nintendo發行的Metroid: Other M / Wii
Nintendo發行的The Legend of Zelda: Skyward Sword / Wii
獲獎 (Winner):
Nintendo發行的Metroid: Other M / Wii

2010年7月21日 星期三

Best of E3 2010 Awards - Best Online Only Game

入選 (Nominees):
SOE發行的The Agency / PC, PlayStation 3
SOE發行的DC Universe Online / PC, PlayStation 3
Trion Worlds發行的End of Nations / PC
Square Enix發行的Final Fantasy XIV / PC, PlayStation 3
LucasArts & EA發行的Star Wars: The Old Republic / PC
獲獎 (Winner):
LucasArts & EA發行的Star Wars: The Old Republic / PC

Best of E3 2010 Awards - Best New IP

 入選 (Nominees):
EA發行的Bulletstorm / PC, PlayStation 3, Xbox 360
Ubisoft發行的Child of Eden / PlayStation 3, Xbox 360
THQ發行的Devil's Third / PlayStation 3, Xbox 360
Bethesda發行的Rage / PC, PlayStation 3, Xbox 360
Sega發行的Vanquish / PlayStation 3, Xbox 360
獲獎 (Winner):
Bethesda發行的Rage / PC, PlayStation 3, Xbox 360

Best of E3 2010 Awards - Best Multiplayer

入選 (Nominees):
Ubisoft發行的Assasin's Creed: Brotherhood / PC, PlayStation 3, Xbox 360
Microsoft發行的Gears of War 3 / Xbox 360
Square Enix發行的Kane & Lynch 2: Dog Days / PC, PlayStation 3, Xbox 360
SCEA發行的LittleBigPlanet 2 / PlayStation 3
SCEA發行的Twisted Metal / PlayStation 3
獲獎 (Winner):
Ubisoft發行的Assasin's Creed: Brotherhood / PC, PlayStation 3, Xbox 360

Best of E3 2010 Awards - Most Innovative

入選 (Nominees):
Microsoft發行的Kinect
Sony發行的LittleBigPlanet 2
Nintendo發行的Nintendo 3DS
MTV Games發行的Rock Band 3
2K Games發行的Spec Ops: The Line
獲獎 (Winner):
Nintendo發行的Nintendo 3DS

Best of E3 2010 Awards - Biggest Surprise

入選 (Nominees):
Gabe Newell Buries the Hatchet with sony
Kid lcarus Returns
The 3DS... it works
Twisted Metal Resurrects Car Combat
Xbox 360 Slims Down
獲獎 (Winner):
The 3DS

2010年7月19日 星期一

Best of E3 2010 Awards - Best PSP Game

入選 (Nominees):
SCEA發行的God of War: Ghost of Sparta
Square Enix發行的Kingdom Hearts: Birth by Sleep
SCEA發行的Patapon 3
Square Enix發行的The 3rd Birthday
SCEA發行的Valkyria Chronicles 2
獲獎 (Winner):
SCEA發行的God of War: Ghost of Sparta

Best of E3 2010 Awards - Best Downloadable Game

入選 (Nominees):
Microsoft發行的Hydrophobia / Xbox 360
Square Enix發行的Lara Croft and the Guardian of Light / Playstation 3, Xbox 360
Playdead發行的Limbo / Xbox 360
Ubisoft發行的Scott Pilgrim vs. the World / Playstation 3, Xbox 360
EA發行的Shank / PC, Playstation 3, Xbox 360
獲獎 (Winner):
Microsoft發行的Hydrophobia / Xbox 360

Best of E3 2010 Awards - Best Driving Game

入選 (Nominees):
Ubisoft發行的Driver: San Francisco / PC, Playstation 3, Xbox 360
Codemasters發行的F1 2010 / PC, Playstation 3, Xbox 360
SCEA發行的Gran Turismo 5 / Playstation 3
SCEA發行的MotorStorm Apocalypse / Playstation 3
Atari發行的Test Drive Unlimited 2 / PC, Playstation 3, Xbox 360
獲獎 (Winner)
SCEA發行的Gran Turismo 5 / Playstation 3

2010年7月17日 星期六

Best of E3 2010 Awards - Best First-Person Shooter

入選 (Nominees):
Epic Games發行的Bulletstorm / PC, PlayStation 3, Xbox 360
Ubisoft發行的Ghost Recon: Future Soldier / PC, PlayStation 3, Xbox 360
Microsoft發行的Halo: Reach / Xbox 360
SCEA發行的Killzone 3 / PlayStation 3
Bethesda發行的RAGE / PC, PlayStation 3, Xbox 360
獲獎 (Winner):
Bethesda發行的RAGE / PC, PlayStation 3, Xbox 360

Best of E3 2010 Awards - Best Graphics

入選 (Nominees):
Electronic Arts發行的Crysis 2 / PC, PlayStation 3, Xbox 360
Microsoft發行的Gears of War 3 / Xbox 360
SCEA發行的Killzone 3 / PlayStation 3
SCEA發行的MotorStorm Apocalypse / PlayStation 3
Nintendo發行的Kirby's Epic Yarn / Wii
Bethesda發行的Rage / PC, PlayStation 3, Xbox 360
獲獎 (Winner):
Nintendo發行的Kirby's Epic Yarn / Wii

Best of E3 2010 Awards - Best 3D Graphics

入選 (Nominees):
Electronic Arts發行的Crysis 2 / PC, PlayStation 3, Xbox 360
SCEA發行的Gran Turismo 5 / PlayStation 3
SCEA發行的Killzone 3 / PlayStation 3
SCEA發行的MotorStorm Apocalypse / PlayStation 3
Nintendo發行的Star Fox 64 / Nintendo 3DS
獲獎 (Winner):
SCEA發行的Killzone 3 / PlayStation 3

Best of E3 2010 Awards - Best Trailer

入選 (Nominees):
Ubisoft發行的Assassins Creed: Brotherhood / PC, PlayStation 3, Xbox 360
Komija發行的Metal Gear Solid: Rising / PC, PlayStation 3, Xbox 360
Valve發行的Portal 2 / PC, PlayStation 3, Xbox 360
LucasArts發行的Star Wars: The Force Unleashed II / PlayStation 3, Xbox 360
Electronic Arts發行的Star Wars: The Old Republic / PC
獲獎 (Winner):
Komija發行的Metal Gear Solid: Rising / PC, PlayStation 3, Xbox 360

2010年7月12日 星期一

Best of E3 2010 Awards - Best Nintendo DS Game

入選:
Square Enix發行的Dragon Quest IX: Sentinels of the Starry Skies
Square Enix發行的Final Fantasy: Four Heros of Light
Capcom發行的Ghost Trick: Phantom Detective
Capcom發行的Okamiden
Warner Bros發行的Super Scribblenauts
獲獎:
Capcom發行的Okamiden

Best of E3 2010 Awards - Best Third-Person Shooter

入選:
Microsoft發行的Gears of War 3 / Xbox 360
Square Enix發行的Kane & Lynch 2: Dog Days / PC, PlayStation 3, Xbox 360
2K Games發行的Mafia II / PC, PlayStation 3, Xbox 360
2K Games發行的Spec Ops: The Line / PC, PlayStation 3, Xbox 360
Sega發行的Vanquish / PlayStation 3, Xbox 360
獲獎:
Microsoft發行的Gears of War 3 / Xbox 360

2010年7月7日 星期三

Best of E3 2010 Awards - Best Wii Game

入選:
Disney發行的Disney Epic Mickey
Nintendo發行的Donkey Kong Country Returns
Nintendo發行的Kirby's Epic Yarn
Nintendo發行的The Legend of Zelda: Skyward Sword
Nintendo發行的Metroid: Other M
獲獎:
Nintendo發行的Metroid: Other M

Best of E3 2010 Awards - Best Xbox 360 Game

入選:
Ubisoft發行的Assassin's Creed: Brotherhood
Microsoft發行的Gears of War 3
Microsoft發行的Halo: Reach
Valve發行的Portal 2
Bethesda發行的Rage
獲獎:
Bethesda發行的Rage 

2010年7月6日 星期二

Best of E3 2010 Awards - Best PlayStation 3 Game

入選:
Ubisoft發行的Assassin's Creed: Brotherhood
SCEA發行的Killzone 3
SCEA發行的Little Big Planet 2
Valve發行的Portal 2
Bethesda發行的Rage
獲獎:
Bethesda發行的Rage

2010年7月5日 星期一

Best of E3 2010 Awards - Best PC Game

入選:
Ubisoft發行的Assassin's Creed: Brotherhood
Valve發行的Portal 2
Bethesda發行的Rage
2K Games發行的Spec Ops: The Line
Electronic Art發行的Stas Wars: The Old Republic
獲獎:
Bethesda發行的Rage

Best of E3 2010 Awards - Best Fighting Game

入選:
Spike Games發行的Deadiest Warrior: The Game / PlayStation 3, Xbox 360
Capcom發行的Marvel vs. Capcom 3: Fate of Two Worlds / PlayStation 3, Xbox 360
EA Sports發行的EA Sports MMA / PlayStation 3, Xbox 360
WB Games發行的Mortal Kombat / PlayStation 3, Xbox 360
THQ發行的WWE Smackdown vs.Raw 2011 / PlayStation 3, Xbox 360
獲獎:
WB Games發行的Mortal Kombat / PlayStation 3, Xbox 360

Best of E3 2010 Awards - Game of the Show

入選:
Unisoft發行的Assassin's Creed: Brotherhood
Microsoft發行的Gears of War 3
Nintendo發行的Metroid: Other M
Valve發行的Portal 2
id Software發行的Rage
獲獎:
id Software發行的Rage

2010年7月4日 星期日

Best of E3 2010 Awards

E3是由英文Electronic Entertainment Expo的3個字首字母E的組合,中文譯名是電子娛樂展。1995年到開始,E3已經有15年的歷史,是每年全球最大的電腦遊戲盛會。
今年2010年的E3大展從6月15日到6月17日,在洛杉磯會議中心(Los Angeles Convention Center,LACC)舉行。隨著大展的落幕各項評選也呼之欲出,包括:
最佳遊戲、最佳RPG遊戲、最佳體育遊戲、最佳動作遊戲、最佳益趣遊戲、最佳駕駛遊戲、最佳音樂遊戲、最佳格鬥遊戲、最佳第三人稱射擊遊戲、最佳第一人稱射擊遊戲、最佳多人遊戲、最佳線上遊戲、最佳下載遊戲、最令人失望、最尷尬的、最具創新、最佳新秀、最大驚喜、最佳圖形技術、最佳3D圖形技術、最佳新聞發佈會、最佳軟體產品…等。
http://www.gametrailers.com/game/best-of-e3-2010-awards/13215

2010年7月1日 星期四

Android程式設計 (十四) 功能表設計

功能表是GUI中基本的操作介面,考量螢幕尺寸及作業便利性,Android應用程式功能表是以浮動方式處理,當按下「Menu」鍵時才開啟應用程式的功能表。
產生功能表作業之程式框架
由Source功能表點選「Override/Implement Methods...」功能表項目開啟「Override/Implement Methods」對話視窗,然後由「Select methods to override or implements:」清單中勾選onCreateOptionsMenu(Menu)onOptionsItemSelected(MenuItem)項目,ADT就會產生應用程式功能表作業所需的程式框架。
建立功能表項目
首先必須在onCreateOptionsMenu()方法中建立功能表項目,我們可使用add()方法加入功能表項目。另外,可使用setIcon()方法為功能表項目設定圖示。
以下程式碼會將「關於…」及「結束…」二個功能表項目加入到應用程式功能表中。
final int MENU_ABOUT = 0;
final int MENU_QUIT = 1;@Override
public boolean onCreateOptionsMenu (Menu menu) {
    // TODO Auto-generated method stub
    final int ICON_ABOUT = android.R.drawable.ic_menu_help;
    final int ICON_QUIT = android.R.drawable.ic_menu_close_clear_cancel;
    menu.add (0, MENU_ABOUT, 0, "關於");
    menu.add (0, MENU_QUIT, 0, "結束");
    menu.getItem (MENU_ABOUT).setIcon (ICON_ABOUT);
    menu.getItem (MENU_QUIT).setIcon (ICON_QUIT);
    return super.onCreateOptionsMenu (menu);
}
撰寫功能表項目之作業程式碼
由於所有功能表項目是共用一個處理程序,程式中可透過getItemId()方法來區辨目前是那一個功能表項目被觸動,並針對每一個功能表項目分別撰寫作業程式碼。
例如當使用者按下「關於…」,程式要顯示「關於」對話盒,這部份可套用先前介紹的AlertDialog物件;而當使用者按下「結束…」,則直接呼叫Android內建的finish()函式關閉目前的activity。
public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    switch (item.getItemId()){
        case MENU_ABOUT:
            openAboutDialog();
            break;
        case MENU_QUIT:
            finish();
            break;
    }
    return super.onOptionsItemSelected(item);
}
private void openAboutDialog() {
    AlertDialog dialog = new AlertDialog.Builder(MainActivity.this).create();
    dialog.setTitle("關於遊戲科學");
    dialog.setMessage("南開科技大學電子工程系電腦遊戲設計組");
    dialog.setButton("Yes", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
        }
    });
    dialog.show();
}

2010年6月26日 星期六

Android程式設計 (十三) 使用Notification

Notification提供跨Activity之訊息通知機制,Activity收到的通知訊息會顯示在狀態欄,使用者可從狀態欄拖出完整版面以檢視Notification詳細內容。
要使用訊息提醒功能,需要匯入以下類別:
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
Notification都是由NotificationManager管理,因此應用程式必須先取NotificationManager參照,做法如下:
NotificationManager nManager = (NotificationManager) getSystemService (NOTIFICATION_SERVICE);
接著建立Notification實體,其中第1個參數為出現在狀態欄的圖示,第2個為訊息標題,第3個參數為Notification建立時間。
Notification nMsg = new Notification(R.drawable.icon, "重要訊息", System.currentTimeMillis());
接下來是建立PendingIntent實體,PendingIntent用來封裝Intent,以便將所封裝的Intent提供給其它應用程式使用,外部應用程式執行這個PendingIntent時,就能間接調用裡面的Intent。做法如下:
PendingIntent pIntent = PendingIntent.getActivity(this,0,new Intent(this, MainActivity.class),PendingIntent.FLAG_UPDATE_CURRENT);
getActivity()方法的第1個參數是目前應用程式的Context,簡單說就是目前應用程式的狀態。getActivity()方法的第2個參數目前保留不使用。第3個參數即是提供給外部應用程式用來啟動Activity的Intent實體。第4個參數通常設定為FLAG_UPDATE_CURRENT表示如果PendingIntent已存在,則更新其資料。
接下來是設定Notification內容,使用Notification的setLatestEventInfo()方法指定Notification標題及內容。最後再使用NotificationManager的Notify()方法發佈Notification即可。
nMsg.setLatestEventInfo(this,"南開科大","電腦遊戲設計組歡迎加入!",pIntent);
nManager.notify(0, nMsg);
透過PendingIntent機制,可發現即使送出Notification的應用程式已終止執行,只要點撃Notification訊息內容,Notification管理程式即可透過封存在PendingIntent裡的Context及Intent,重新啟動Intent中的Activity。

2010年6月16日 星期三

遊戲大廠的人機介面大戰

Wii Remote
Wii最先於2005年9月17日於東京電玩展上發表Wii Remote,取代傳統遙控器。結合三軸加速感測技術來達到指向定位及動作感應,除了可以控制螢幕上的游標,還可偵測三維空間當中的移動及旋轉,結合兩者可以達成所謂的「體感操作」。玩者可以透過移動和指向來與電視螢幕上的虛擬物件產生互動,此外也可藉由連接擴充設備延伸控制器的功能。
Wii Remote對玩家有相當引力,推出後嚴重衝擊遊戲市場,但由於專利保護,其它遊戲大廠只能設法開發其它技術。

(Wii Remote)
PlayStation Move
Sony在2010年3月的GDC(遊戲開發者大會)發表PlayStation Move,包括PlayStation Eye(攝影機)、PlayStation Move navigation controller(一般遙控器)及PlayStation Move motion controller(動作感測)。Move motion controller是一支像螢光棒的體感控制手把,搭配攝影機檢知及分析光點來感測遊戲者動作。
(PlayStation® Move motion controller)
Kinect for Xbox 360
微軟在2010 年 6月E3 展發表 Kinect for Xbox 360,這次連遙控器都免了。Kinect 透過紅外線感測、影像處理及語音辦識技術,追蹤偵測玩家的身體動作、姿勢、以及聲音辨識,遊戲者的動作就是控制器。不論男女老少,Kinect 讓玩家能立即融入遊戲當中,以直覺方式玩戲,還會將遊戲中的精彩境頭自動拍照。

2010 E3微軟發表KINECT

2010 年6月 E3 展,微軟發表 Kinect for Xbox 360,透過紅外線感測、影像處理及語音辦識技術,擺脫傳統遙控器之限制,遊戲者的動作就是控制器。Kinect 可追蹤玩家的身體動作、姿勢、以及聲音辨識,不論男女老少,Kinect 讓玩家能立即融入遊戲當中,以直覺方式玩戲。看到球來了,踢下去就是了;有障礙物,直接跳過去;想學跳舞,跟著螢幕上初學者舞步搖擺就對了。
微軟也同步發表Kinect Adventures、Kinectimals、Kinect Joy Ride、Kinect Sports、Dance Central、Your Shape:Fitness Evolved等8種包括冒險、養成、賽車、運動、跳舞的Kinect遊戲,其中Your Shape:Fitness Evolved結合玩家投影(Player Projection)技術,直接將你的形體融入遊戲中,並與虛擬環境進行互動,你的分身在遊戲內動作所產生的獨特視覺效果與震撼力也令人稱奇。另外微軟也宣布明年將與和LucasArts攜手推出的Star Wars星際大戰遊戲,迪士尼也將為Xbox 360推出Kinect版遊戲。
Kinect for Xbox 360 即將在 11 月 4 日在北美上市,並陸續拓展到全球。
(圖片來源: 台灣微軟)

2010年6月13日 星期日

Android程式設計(十二) Activity互動作業-2

處理Activity間資料傳遞
要傳遞資料給被啟動的Activity,啟用端Activity必須先使用putExtra()方法以name-value pair方式設定所要傳遞的資料。putExtra()方法第1個參數代表資料名稱,第2個參數則是為資料內容,如需要傳遞多筆資料,只要重複使用putExtra()方法即可。例如:
Intent intent = new Intent (MainActivity.this, Activity1.class);
intent.putExtra ("REQ1", "MainActivity傳遞的資料1");
intent.putExtra ("REQ2", "MainActivity傳遞來的資料2");
startActivity (intent);
被啟動的Activity,必須先使用getIntent()方法取得傳來的「Intent」物件,再透過getExtras()方法取得資料包(bundle),然後使用getString()等方法讀取指定資料。例如:
Bundle params = getIntent().getExtras();
if (params! = null) {
    temp = params.getString ("REQ1") + "\n" + params.getString ("REQ2");
    Toast.makeText (Activity1.this, temp, Toast.LENGTH_LONG).show();
}
如果啟用端想要由被啟動的Activity取得回傳資料,那麼啟用端必須改用startActivityForResult()方法來啟動Activity,並覆寫onActivityResult()方法來處理被啟動之Activity所回傳的資料。
startActivityForResult()方法的第二個參數為自訂的請求碼,主要是做為雙方溝通的標記,這個請求碼會在onActivityResult()方法中的第一個參數被傳回,以便onActivityResult()程式驗證回傳者身份。
//MainActivity.java
public class MainActivity extends Activity {
    final int MY_ID = 100;
    @Override
    public void onCreate (Bundle savedInstanceState) {
        Button btnobj;
        super.onCreate (savedInstanceState);
        setContentView (R.layout.main);
        btnobj = (Button) findViewById (R.id.btnINVOKE02);
        btnobj.setOnClickListener (InvokeActivity2);
    }
    private Button.OnClickListener InvokeActivity2 = new Button.OnClickListener () {
        public void onClick (View v) {
            Intent intent = new Intent (MainActivity.this, Activity2.class);
            intent.putExtra ("REQ1", "MainActivity傳遞的資料1");
            intent.putExtra ("REQ2", "MainActivity傳遞的資料2");
            startActivityForResult (intobj, MY_ID);
        }
    };
    @Override
    protected void onActivityResult (int requestCode, int resultCode, Intent data) {
        super.onActivityResult (requestCode, resultCode, data);
        if (requestCode == MY_ID){
            String temp = null;
            Bundle results = data.getExtras ();
            if (results != null){
                temp = results.getString ("ACK1") + results.getString ("ACK2");
                Toast.makeText (MainActivity.this, temp, Toast.LENGTH_LONG).show();
            }
        }
    }
}
被啟動的Activity端所要回傳的資料亦是使用putExtra ()方法設定name-value pair,之後再使用setResult ()方法回傳資料。
//Activity2.java
public class Activity2 extends Activity {
    final int ACK = 200;
    @Override
    protected void onCreate (Bundle savedInstanceState) {
        Button btnobj;
        super.onCreate (savedInstanceState);
        setContentView (R.layout.activity2);
        btnobj = (Button) findViewById (R.id.btnRETURN);
        btnobj.setOnClickListener (CloseActivity2);
        String temp = null;
        Bundle params = getIntent().getExtras();
        if (params! = null){
            temp = params.getString ("REQ1") + "\n" + params.getString ("REQ2");
            Toast.makeText (Activity2.this, temp, Toast.LENGTH_LONG).show();
        }
    }
    private Button.OnClickListener CloseActivity2 = new Button.OnClickListener() {
        public void onClick (View v) {
            Intent intent = new Intent ();
            intent.putExtra ("ACK1", "Activity2傳回的資料1");
            intent.putExtra ("ACK2", "Activity2傳回的資料2");
            setResult (ACK, intent);
            finish ();
        }
    };
}

2010年6月11日 星期五

遊戲類型(十四) RSG 養成類游戲 (Raising Sims Game)

養成類游戲由玩家扮演培育者的角度來進行的一種電子遊戲類型,主要在觀察被培育者隨著不同的栽培方式而產生的變化。
(Nat Geo Games:DogTown, 狗鎮)

2010年6月9日 星期三

Android程式設計(十一) Activity互動作業-1

在Android中,Activity間作業切換或資料傳遞,都必須透過Intent機制。要使用Intent功能,應用程式需要匯入以下類別
import android.content.Intent;
Activity間不傳遞資料
如果我們只要從一個作業書面切換到另一個作業畫面,這二個Activity間不需要資料交換,這種作業很簡單,只要設定好Intent的內容與動作,並把Intent做為startActivity方法之參數,即可啟動另一個Activity。
Intent intent = new Intent (CurrentActivity.this, InvokedActivity.class);
startActivity (intent);
當被啟動的Activity結束(finish),程式會自動返回原Activity。
1. 新增專案。
2. 在專案中加入二個Activity類別:MainActivity.java 及Activity1.java (AndroidMainfest.xml內的<activity>描述也要一併更新)
3. 修改MainActivity 及Activity1使用者介面
4. 修改MainActivity 及Activity1程式碼
//MainActivity.java
public class MainActivity extends Activity {
    @Override
    public void onCreate (Bundle savedInstanceState) {
        Button btnobj;
        super.onCreate (savedInstanceState);
        setContentView (R.layout.main);
        btnobj = (Button) findViewById (R.id.btnINVOKE01);
        btnobj.setOnClickListener (InvokeActivity1);
    }
    private Button.OnClickListener InvokeActivity1 = new Button.OnClickListener () {
        public void onClick (View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent (MainActivity.this, Activity1.class);
            startActivity (intent);
        }
    };
}
//Activity1.java
public class Activity1 extends Activity {
    @Override
    protected void onCreate (Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        Button btnobj;
        super.onCreate (savedInstanceState);
        setContentView (R.layout.activity1);
        btnobj = (Button) findViewById (R.id.btnCLOSE);
        btnobj.setOnClickListener (CloseActivity1);
    }
    private Button.OnClickListener CloseActivity1 = new Button.OnClickListener () {
        public void onClick (View v) {
            // TODO Auto-generated method stub
            finish ();
        }
    };
}

Android程式設計(十二) Activity互動作業-2