山姆的編程實作分享。。。

Sam Blog, Sam Sharing, Sam Studio

2015年1月20日

[心得] Clash of Clans (部落衝突)


App 名稱  : Clash of Clans (部落冲突), 簡稱 COC,

App Icon:如右圖

類別:戰略遊戲

平台:iOS, Android

開發商:芬蘭 Supercell

發行日:iOS 2012/8/2, Android 2013/10/7

個人是在2013年10月底開始接觸這款遊戲,也就是Supercell發行Android版本後,從兒子口中得知國中生在玩這款遊戲, 於是也下載來玩來,以了解兒子在玩怎樣的遊戲.

這遊戲ㄧ開始吸引我的地方是畫面的精緻度及村莊經營的成就感,當然以上這兩點是不足以讓我足足玩了一整年,是"部落"這元素讓我無法停手,這其中包含對部落責任及追求部落排名的成就感.

這遊戲最重要的一個元素就是"部落",
  • 你可以不加入任一部落,自己慢慢的經營村莊, 但我可以告訴你,遊戲的精髓你沒玩到,而且相信不久之後,你會是一隻"死魚".
  • 透過"部落聊天室",成員可以交流,聊天,讓你有歸屬感
  • 透過"攻擊"影片的分享,可以滿足個人的成就感或修正攻擊方式
  • 透過"被攻擊"影片的分享,可以了解如何部陣,了解別人是如何搶資源
2014/4/9, Supercell 導入會戰 (clan wars),增加這遊戲的刺激性
  • 有了會戰,遊戲不再只是搶資源,升級防禦及攻擊力
  • 有了會戰,遊戲不再是"一對一"的比拼,是10vs10,15vs,...,45vs45,50vs50的團體戰

另外,有一點要特別提出的是,如果你不介意花在這款遊戲的時間比人多或是你口袋不夠深,這款遊戲是可以不花一毛錢還是可以玩到大神的境界,因為遊戲中任何建物,英雄,兵種,科技都可透過搶奪資源累積而來,當然對於口袋夠深玩家是可以透過寶石秒得,也就說人人都有機會成為大神,差別只在於時間.

如果你是喜歡戰鬥策略遊戲,這遊戲是值得你一試的

下圖是我的村莊



PS:
直到2013/4,
Supercell 有Clash of Clans 及 Hay Day 兩款遊戲在App Store 販售,
這兩款遊戲每日為Supercell 賺取 $2.4 million

2015年1月13日

Java not found during install Android Studio


You may meet a same problem with me during install Android Studio.
System prompts below message box to you and your computer already has JDK 7 or JDK 8 actually.


To check whether your JDK exists in your  computer or not, you can type java -version command in Terminal application


According to Android Development website, Android Studio needs JDK6 or higher.
So what this problem is...

The problem is at info.plist inside Android Studio package 
You can open info.plist file, the content should same as below


Please modify value of JVMVersion from 1.6* to 1.6+ then save the file.

Hope, this information can solve your problem. 







2015年1月7日

Swift Programming - Fallthrough statement


Swift 的控制轉移敘述 (control transfer statements)共有 break, continue, fallthrough  及 return 四種.

break, continue & return 與Objective-C 同, Fallthrough 是 Swift 新加入的.

Fallthrough 語法定義如下:
Fallthrough 有以下幾點特性:

1. Fallthrough 只會(能)出現在Switch 敘述中的case block

2. Fallthrough 不會檢查 case condition 且直接執行下一個 case block (或default case block)

3. Fallthrough 能出現在最後ㄧ個 case block

資料參考自: Apple, The Swift Programming Language

2015年1月4日

Swift Programming - Switch statement


Swift 的 Switch statement 和 Objective-C 有以下幾點差異

1. 語法定義:

從語法上可以看到,我們不必在每個case statement 後加上break, Swift 會自動結束switch case 區段.

2. 從上面語法定義可以發現, Switch 增加 "where" 關鍵字,它(where condition)提供額外的條件敘述來加強case, 使case 條件更加嚴謹.
例如:
case (let x,  let y) where ( x == y )

3. 每個 case block 必須至少一個 statement, 如果真的沒有要執行的程式碼,那就請加上"break"吧.

The scope of each case can not be empty. As a result, you must include at least one statement following the colon (:) of each case label. Use a single break statement if you don’t intend to execute any code in the body of a matched case

資料來源: Apple, The Swift Programming Language

2015年1月1日

2014年12月29日

Swift Programming - For-In loop statement (迴圈敘述)


Swift 同Objective-C提供了 for, while 及 do-while 迴圈指令 ( loop control construct ), 除此之外, Swift 新增了 for-in loop control; 針對 array, dictionary 及 string 的應用, for-in 有他好用之處.

以下是他的語法定義:


以下我們就用playground來試用 for-in control statement


以下為array 的應用


以下為string 的應用


資料參考來自:
Apple, The Swift Programming Language.

2014年12月19日

Android Studio 1.0 千呼萬喚終於出來了!


Google 在 2013 Google I/O 大會釋放未來會有 Android 專屬的IDE ,終於
2014 年底在 Android 官方網站已經開放下載 Android Studio 1.0



它具有如下幾點特色:
1. Intelligent code editor
2. Code templates and GitHub integration
3. Multi-screen app development
4. Virtual devices for all sharps and sizes
5. Android builds evolved, with Gradle

詳細的資訊請參考 Android Developer 官網

資料來源:Android Developer 官網

2014年12月16日

『Gartner』Sales of Smartphone in Q3 2014


前五大智慧型手機廠商銷售統計, Samsung 還是第一, 但市佔率已經從32.1%掉到24.4%, 小米已經排名第四了, 大陸廠牌就佔了3位.




















智慧型手機作業系統銷售統計, Android佔了83.1% 和 iOS就吃掉95%的市佔率, Windows只有3%.

















全球手機銷售前十大廠商, 在台灣還賣得不錯的HTC 及 Sony竟然排不上


























資料來源:Gartner

2014年12月4日

Swift Programming - Tuples type (多元組 / 元組)


除了一般我們熟悉的資料型態外, Swift 加入了兩項Objective-C沒有的資料型態
1. Optional (選項型態)
2. Tuples (中文翻譯為 "多元組" or  "元組")

在iOS Computer Language 的世界,Tuples或許是新成員, 但是在Computer Language 的世界早已經可以看到它的足跡, 如C#, Python.

以下是它的語法定義:

從語法的定義可以知道它的宣告方式是由零到多種資料型態用分號分開再由小括號包覆的資料型態.

那Tuples要用在哪?就如 "Swift Programming Language" 文中所說的
Tuples are particularly useful as the return values of functions; Tuples are useful for temporary groups of related values. They are not suited to creation of complex data structures.

也就說,當你想回傳的參數不是單一值又不想定義ㄧ個資料結構時就可以使用Tuples.

另外,你也可以為每一個element命名
You can also name the elements of a tuple type and use those names to refer to the values of the individual elements. An element name consists of an identifier followed immediately by a colon (:).

Tuples常被用在錯誤的處理;
我們可以設想這樣的情境,當我們在處理error code的時候,如果只是回傳數字,對於程式設計員是足夠的且很好處理,但是對於終端的維修人員是可讀性低且必須查表才知道機器錯誤的原因,這是很不好的ㄧ種的設計; 相反的, 如果我們可以同時回傳字串的話那就比較符合人性.


資料參考來自:
Apple Inc. The Swift Programming Language.

2014年12月1日

Swift Programming - Optional type (選項型態)


除了一般我們熟悉的資料型態外, Swift 加入了兩項Objective-C沒有的資料型態
1. Optional (選項型態)
2. Tuples

選項型態 (optional type)在 "The Swift Programming Language" 文章中是這樣形容它的,

Optionals handle the absence of a value. Optionals say either “there is a value, and it equals x” or “there is not a value at all”. Optionals are similar to using nil with pointers in Objective-C, but they work for any type, not just classes. Optionals are safer and more more expressive than nil pointers in Objective-C.

所以選項型態 (optional type)可以說成:
某變數或常數
有值且等於某值(there is a value, and it equals x)

無資料(there is not a value at all)

從語法的定義可以知道它的宣告方式就是在型態名稱後加在?
至於加上!, 則是當確定有資料時,解開選項型態時使用


以下我們就利用Playground來體驗選項型態 (optional type)
從上圖可以發現,
1. 在列印時,因為possibleString 是選項型態,在字串前面會Optional關鍵字.
2. 如果你沒有給選項型態的變數或常數初值,Swift為自動設 "nil" .

下圖為!的使用範例

資料參考來自:
Apple, The Swift Programming Language.

熱門文章