<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-14721237</id><updated>2024-09-20T21:54:08.371+08:00</updated><category term="Android"/><category term="cocos2d-x"/><category term="link"/><category term="ios"/><category term="Other"/><category term="Html5"/><category term="OpenGL"/><category term="Unity"/><category term="temp"/><category term="glsl"/><category term="shader"/><category term="Ogre"/><category term="libgdx"/><category term="ubuntu"/><category term="youtube"/><category term="AppleTV"/><category term="Chromecast"/><category term="Facebook"/><category term="JNI"/><category term="Java"/><category term="Math"/><category term="NDK"/><category term="Sublime"/><category term="Texture Packer"/><category term="ant"/><category term="cURL"/><category term="javascript"/><category term="plugin"/><category term="出包"/><title type='text'>雜物聚集地</title><subtitle type='html'>各樣筆記</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>96</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-14721237.post-5490853913249806592</id><published>2014-11-07T14:48:00.000+08:00</published><updated>2014-11-07T14:49:29.038+08:00</updated><title type='text'>新站啟用</title><content type='html'>改用markdown來寫網誌&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://hsienwei.github.io/&quot;&gt;http://hsienwei.github.io/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
會把一些文章搬過去&lt;br /&gt;
這裡就可能不更新囉</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/5490853913249806592/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/5490853913249806592' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/5490853913249806592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/5490853913249806592'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2014/11/blog-post.html' title='新站啟用'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-2190480612302258213</id><published>2014-08-12T18:04:00.000+08:00</published><updated>2014-08-12T18:04:02.879+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AppleTV"/><category scheme="http://www.blogger.com/atom/ns#" term="ios"/><category scheme="http://www.blogger.com/atom/ns#" term="youtube"/><title type='text'>(iOS) Youtube iframe 在 Apple TV 上的播放問題</title><content type='html'>&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;問題：&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;有一個頁面使用WebView + Youtube iframe 播放 live channel，在手機上播放正常，但如果使用AirPlay功能cast到Apple TV的話則會出現“ an error occurred loading this content ”。&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;如果播放的是非live則可以正常運行。&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;處置：&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;用電腦開啓Plex Home Theater作為測試裝置，可以播放live，故應該不是AirPlay本身不支援live。&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;由於以相同的程式碼來作處理時，單則節目可以播放而live不行，故認為是Apple TV那邊無法處理。&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;Apple TV裡的Youtube app 完全搜尋不到Live的節目。&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;一開始懷疑是訊號來源問題，比方是否為Apple TV無法處理Youtube廣告要求，但查明目前並沒有廣告。&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;後來發現Youtube官方iOS app並不會有這樣的問題，懷疑如果我不透過iframe的方式也許可以處理。&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;最後使用&lt;/span&gt;&lt;span style=&quot;color: #042eee; font-family: Arial; font-size: 13px;&quot;&gt;&lt;u&gt;&lt;a href=&quot;https://github.com/hellozimi/HCYoutubeParser&quot;&gt;https://github.com/hellozimi/HCYoutubeParser&lt;/a&gt;&lt;/u&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;來做處理，取得直接播放的URL，則可正常在Apple TV上播放。&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;在使用HCYoutubeParser上需要小心，因為Youtube曾經&lt;/span&gt;&lt;span style=&quot;color: #042eee; font-family: Arial; font-size: 13px;&quot;&gt;&lt;u&gt;&lt;a href=&quot;https://github.com/hellozimi/HCYoutubeParser/pull/30&quot;&gt;改變過responceData&lt;/a&gt;&lt;/u&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;，所以會有不能用的風險，這個要自行承擔。&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/2190480612302258213/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/2190480612302258213' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/2190480612302258213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/2190480612302258213'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2014/08/ios-youtube-iframe-apple-tv.html' title='(iOS) Youtube iframe 在 Apple TV 上的播放問題'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-6638913838315441756</id><published>2014-06-27T02:51:00.000+08:00</published><updated>2014-06-27T02:59:59.372+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="plugin"/><category scheme="http://www.blogger.com/atom/ns#" term="Sublime"/><category scheme="http://www.blogger.com/atom/ns#" term="Unity"/><title type='text'>使用sublime為unity編輯器 in mac 之 CompleteSharp設定障礙排除</title><content type='html'>&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;標題下得很長&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;基本上是記載依照&lt;/span&gt;&lt;span style=&quot;color: #042eee; font-family: Arial; font-size: 13px;&quot;&gt;&lt;u&gt;http://wiki.unity3d.com/index.php/Using_Sublime_Text_as_a_script_editor&lt;/u&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;的步驟進行時&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;CompleteSharp這個plugin在mac環境上遇到的一些問題&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;1. CompleteSharp的安裝&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;個人測試在windows可以用package control直接安裝成功&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;而在mac下會出現Unable to download CompleteSharp的錯誤&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;這時候只能手動安裝&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;有兩種選擇&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;a) clone &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #042eee; font-family: Arial; font-size: 13px;&quot;&gt;&lt;u&gt;https://github.com/ewilde/CompleteSharp&lt;/u&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&amp;nbsp;到 Package資料夾&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;不需其他處理(建議)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;b) 需事先安裝mono (下載&lt;/span&gt;&lt;span style=&quot;color: #042eee; font-family: Arial; font-size: 13px;&quot;&gt;&lt;u&gt;http://www.go-mono.com/mono-downloads/download.html&lt;/u&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;clone &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #042eee; font-family: Arial; font-size: 13px;&quot;&gt;&lt;u&gt;https://github.com/quarnster/CompleteSharp&lt;/u&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&amp;nbsp;到 Package資料夾&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;再執行CompleteSharp/build.py&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;2. CompleteSharp project setting&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;在mac環境中會用到completesharp_mono_path這個參數&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;wiki中寫的completesharp_mono_path是3.x 版時的路徑&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;4.x版可改為如下&lt;/span&gt;&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/hsienwei/ad4564e649a60996d9b0.js&quot;&gt;&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/6638913838315441756/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/6638913838315441756' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/6638913838315441756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/6638913838315441756'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2014/06/sublimeunity-in-mac-completesharp.html' title='使用sublime為unity編輯器 in mac 之 CompleteSharp設定障礙排除'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-7997043581375052819</id><published>2014-06-06T15:00:00.000+08:00</published><updated>2014-06-06T15:00:28.697+08:00</updated><title type='text'>Crashlytics 申請使用記錄</title><content type='html'>&lt;div class=&quot;ennote&quot; style=&quot;-webkit-line-break: after-white-space; -webkit-nbsp-mode: space; word-wrap: break-word;&quot;&gt;
&lt;div&gt;
相較於Crittercism&lt;/div&gt;
&lt;div&gt;
Crashlytics專注於crash的記錄與統計&lt;/div&gt;
&lt;div&gt;
且目前為免費使用（2014/6/6）&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
要申請Crashlytics帳號必須先在&lt;a href=&quot;http://try.crashlytics.com/&quot;&gt;http://try.crashlytics.com/&lt;/a&gt;留下你的資料&lt;/div&gt;
&lt;div&gt;
個人經驗是下午三點申請大概晚上9點就回覆你了&lt;/div&gt;
&lt;div&gt;
會收到兩封信&lt;/div&gt;
&lt;div&gt;
一封是Invitation&lt;/div&gt;
&lt;div&gt;
另一封是確認你有沒有收到Invitation的信件會要求你回覆（我有回覆，但感覺只是CRM的信件）&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
從Invitation裡的按鈕進入並依他的步驟一直往下走會進到下載plugin的頁面&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjygJ42ae828YyQZMD7Pq874e3p5EWe9Fl6TPQVW7c5VwuVPx-5uDARgH0eDsxyXWnj1_BczZYrGeJtonzVKbOYhPA_fFGo37qIQzxjTmNoUA7DkoxkdFn1JNsgccs0boUKqZHa/s1600/20c872b148c50cde0b59847b9ad8a47e-767323.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjygJ42ae828YyQZMD7Pq874e3p5EWe9Fl6TPQVW7c5VwuVPx-5uDARgH0eDsxyXWnj1_BczZYrGeJtonzVKbOYhPA_fFGo37qIQzxjTmNoUA7DkoxkdFn1JNsgccs0boUKqZHa/s320/20c872b148c50cde0b59847b9ad8a47e-767323.png&quot; id=&quot;BLOGGER_PHOTO_ID_6021705928764863586&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
個人覺得這是Crashlytics的特色&lt;/div&gt;
&lt;div&gt;
透過一套plugin讓使用者在設定過程中得到幫助與需要的說明&lt;/div&gt;
&lt;div&gt;
並在有crash時提供一個清單讓你觀看&lt;/div&gt;
&lt;div&gt;
這裡我試裝了XCODE與Eclipse兩個plugin&lt;/div&gt;
&lt;div&gt;
XCODE會出現在右上角系統bar中&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFIMmijSg4zRoAzvlbPbswDVwJTm_7mDbVEj_rxfUQZeZtMU-67v7-eFRychUbA7B_Ox02vl_2vxqxmMAt4x5jfCvbohTGpLG1AeLfqseeY_uMDnB99uYn8A0d5yoaTMHtSArn/s1600/940352bececc230f3db3bbc654ba1292-770386.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFIMmijSg4zRoAzvlbPbswDVwJTm_7mDbVEj_rxfUQZeZtMU-67v7-eFRychUbA7B_Ox02vl_2vxqxmMAt4x5jfCvbohTGpLG1AeLfqseeY_uMDnB99uYn8A0d5yoaTMHtSArn/s320/940352bececc230f3db3bbc654ba1292-770386.png&quot; id=&quot;BLOGGER_PHOTO_ID_6021705944646907890&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
而Eclipse會出現在Eclipse Toolbar當中&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQIaJ7IM2tm1A3IxG_-VMBWf6j4fLVa149J0dqcdiLerq-wQ7T4dW9yMZHUnDy_iV8F9MYTqSJzPUPQKmr5KgcAyO44aIw4YO0L57VL-m3Rfz2G-gBBcdv0YxqdXk0Y1XfP8Tu/s1600/55a952c8a6ee86818406f81d13070956-771720.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQIaJ7IM2tm1A3IxG_-VMBWf6j4fLVa149J0dqcdiLerq-wQ7T4dW9yMZHUnDy_iV8F9MYTqSJzPUPQKmr5KgcAyO44aIw4YO0L57VL-m3Rfz2G-gBBcdv0YxqdXk0Y1XfP8Tu/s320/55a952c8a6ee86818406f81d13070956-771720.png&quot; id=&quot;BLOGGER_PHOTO_ID_6021705962266088658&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
以XCODE版為例&lt;/div&gt;
&lt;div&gt;
一開始按下ICON後會出現以下畫面&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir7LEO7WD0GCT-lyUPvkvoD1kSwg4Vva8NvbNWVMtZ6vEDOaia1e6oighIbQ7kl6LzjhAp9ITpxmIR7tkF15UEwy68c0apJ1v4yA8FgkuJmj0y7cIrnVzTV0dSMYUjV0CL_FnZ/s1600/797ee9ab8961ab14fac9c7e27d20dee9-777744.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir7LEO7WD0GCT-lyUPvkvoD1kSwg4Vva8NvbNWVMtZ6vEDOaia1e6oighIbQ7kl6LzjhAp9ITpxmIR7tkF15UEwy68c0apJ1v4yA8FgkuJmj0y7cIrnVzTV0dSMYUjV0CL_FnZ/s320/797ee9ab8961ab14fac9c7e27d20dee9-777744.png&quot; id=&quot;BLOGGER_PHOTO_ID_6021705971606075266&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
基本上就是將我的XCODE專案都列出來方便我選擇要使用Crashlytics的專案&lt;/div&gt;
&lt;div&gt;
在這裡選擇專案以後會出現設定的說明如下&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVJanJay5oNDSy28B2st9LbA3sDISAB4L9D0pYers18G4IpAXiFCh8hv2QPzBo1QQAYza8ybH9jMNCwIe0Gsf1AaScL-YVRPGe6CU9fC0p5meNur9ftmTrJt-0ZsfZfk7mIe-w/s1600/63978861f8946d0823a5c0d2ffaa4727-779625.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVJanJay5oNDSy28B2st9LbA3sDISAB4L9D0pYers18G4IpAXiFCh8hv2QPzBo1QQAYza8ybH9jMNCwIe0Gsf1AaScL-YVRPGe6CU9fC0p5meNur9ftmTrJt-0ZsfZfk7mIe-w/s320/63978861f8946d0823a5c0d2ffaa4727-779625.png&quot; id=&quot;BLOGGER_PHOTO_ID_6021705982424116386&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
這裡說明了要你在target中加一個Run Script並將設定內容列出來&lt;/div&gt;
&lt;div&gt;
要注意的是這裡已經幫你在該專案中加了Crashlytics.framework&lt;/div&gt;
&lt;div&gt;
當你完成設定並build之後他就會進到接下來的步驟像是framework設置以及程式碼的增加&lt;/div&gt;
&lt;div&gt;
我覺得這個教學的步驟對新手而言可以保證他設定完成&lt;/div&gt;
&lt;div&gt;
但對有經驗的人可能有點多餘&lt;/div&gt;
&lt;div&gt;
另外提一下，Eclipse版在選完專案後甚至幫你把Androidmanifest.xml設定與程式碼加進去&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
設定完成後就可以開始故意讓程式crash來測試&lt;/div&gt;
&lt;div&gt;
此時crash就會出現在清單中了&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf1ZF4BkWc-hdrAm-7hXJVNpjA28wRFw7_kud_9khrFzWgdq5zaz6aUP-PDCALTyhgAYG6-QJdiRPUOmVoow-AigGSNVS9gTXKGIB_gB-0nKi9PFSck_DRh6IECwq4efgnJwvF/s1600/3986cc0128d372e0c7b7f942da8bf0bc-781673.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf1ZF4BkWc-hdrAm-7hXJVNpjA28wRFw7_kud_9khrFzWgdq5zaz6aUP-PDCALTyhgAYG6-QJdiRPUOmVoow-AigGSNVS9gTXKGIB_gB-0nKi9PFSck_DRh6IECwq4efgnJwvF/s320/3986cc0128d372e0c7b7f942da8bf0bc-781673.png&quot; id=&quot;BLOGGER_PHOTO_ID_6021705988676223554&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
根據個人測試，plugin上的crash清單反應似乎沒有web快，需要多等幾分鐘才會出現&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
點擊清單上的crash項目後會在瀏覽器上開啟該crash的詳細訊息&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwJLyms8Mb06OuJFg2ohGrLdA0q9TGUwOoCoScu3A2P5vpjuV4YA0MyXTkjfIRJP0cHukZ5myw5gq0HCVqg4UZYqUt6jsjDBkd5UBoEBGjD38XvOZcz3pz3I0-nVxxbDd4Ly_i/s1600/01e1ac2287bfd18fb2bc04042b70d818-783958.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwJLyms8Mb06OuJFg2ohGrLdA0q9TGUwOoCoScu3A2P5vpjuV4YA0MyXTkjfIRJP0cHukZ5myw5gq0HCVqg4UZYqUt6jsjDBkd5UBoEBGjD38XvOZcz3pz3I0-nVxxbDd4Ly_i/s320/01e1ac2287bfd18fb2bc04042b70d818-783958.png&quot; id=&quot;BLOGGER_PHOTO_ID_6021706004510726290&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG4RT-UjOM7t85RwN_6cVEX-b-ZlTarQSxxZb9WCTicx2pE-sBkJQ4bE4_-7EROwYLeCPK6dAfnW28rPdjA9W7bkfqSeElqG-VRrfqunioqcgUwepuidjtGTepfrQnXS6q4R-u/s1600/1d56c7548fab83063804a0e779b93f9d-786311.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG4RT-UjOM7t85RwN_6cVEX-b-ZlTarQSxxZb9WCTicx2pE-sBkJQ4bE4_-7EROwYLeCPK6dAfnW28rPdjA9W7bkfqSeElqG-VRrfqunioqcgUwepuidjtGTepfrQnXS6q4R-u/s320/1d56c7548fab83063804a0e779b93f9d-786311.png&quot; id=&quot;BLOGGER_PHOTO_ID_6021706011428285154&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
此時就可以依照錯誤訊息除錯囉&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
P.s. 尚未測試過，不確定NDK crash狀況是否可以正確呈現&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-top: 1px solid #d3d3d3; margin-bottom: 16px; margin-top: 32px; padding-top: 16px; width: 100%px;&quot;&gt;    &lt;tbody&gt;
&lt;tr&gt;     &lt;td style=&quot;color: #747474; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px; text-align: left;&quot;&gt;Evernote 幫您記住生活的點點滴滴，輕鬆保持條理。&lt;a href=&quot;https://www.evernote.com/getit?email_name=emailNote&amp;amp;email_guid=cba875b1-1689-40e2-8581-c79bab07ca82&amp;amp;email_link=download_app&quot; style=&quot;color: #5fb336; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;下載 Evernote&lt;/a&gt;。     &lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/7997043581375052819/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/7997043581375052819' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/7997043581375052819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/7997043581375052819'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2014/06/crashlytics.html' title='Crashlytics 申請使用記錄'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjygJ42ae828YyQZMD7Pq874e3p5EWe9Fl6TPQVW7c5VwuVPx-5uDARgH0eDsxyXWnj1_BczZYrGeJtonzVKbOYhPA_fFGo37qIQzxjTmNoUA7DkoxkdFn1JNsgccs0boUKqZHa/s72-c/20c872b148c50cde0b59847b9ad8a47e-767323.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-7497032620455867786</id><published>2014-05-19T11:20:00.000+08:00</published><updated>2014-05-19T11:20:14.006+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Chromecast"/><title type='text'>自製2048 for Chromecast</title><content type='html'>&lt;div class=&quot;ennote&quot; style=&quot;-webkit-line-break: after-white-space; -webkit-nbsp-mode: space; word-wrap: break-word;&quot;&gt;
&lt;div&gt;
近日在看Chromecast的相關文件，發現他可以自己做receiver app&lt;/div&gt;
&lt;div&gt;
receiver app是以HTML5來製作 &amp;nbsp;但由於有一些效能限制 所以製作時需要注意&lt;/div&gt;
&lt;div&gt;
詳情可參考&amp;nbsp;&lt;a href=&quot;https://developers.google.com/cast/docs/ux_guidelines#considerations&quot;&gt;https://developers.google.com/cast/docs/ux_guidelines#considerations&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
只要符合條件 &amp;nbsp;基本上也是可以做遊戲的&lt;/div&gt;
&lt;div&gt;
剛好最近很紅的2048是&lt;a href=&quot;https://github.com/gabrielecirulli/2048&quot;&gt;開源&lt;/a&gt;的 &amp;nbsp;所以就以它來當作例子&lt;/div&gt;
&lt;div&gt;
其實2048已經有人移植到chromecast上了&lt;/div&gt;
&lt;div&gt;
但反正是要做一個測驗所以無所謂&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
以下是實際成品的聯結&lt;/div&gt;
&lt;div&gt;
Chrome:&amp;nbsp;&lt;a href=&quot;https://dl.dropboxusercontent.com/u/10581994/chromecast_test/index.html&quot;&gt;https://dl.dropboxusercontent.com/u/10581994/chromecast_test/index.html&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
Android(4.0以上):&amp;nbsp;&lt;a href=&quot;https://dl.dropboxusercontent.com/u/10581994/chromecast_test/2048ForChromecast.apk&quot;&gt;https://dl.dropboxusercontent.com/u/10581994/chromecast_test/2048ForChromecast.apk&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
其實做起來並不難，主要分為兩個部分(receiver and sender)，基本API的用法就不贅述，可以看&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://developers.google.com/cast/docs/developers&quot;&gt;https://developers.google.com/cast/docs/developers&lt;/a&gt;&amp;nbsp; 及&amp;nbsp;&lt;a href=&quot;https://github.com/googlecast/&quot;&gt;https://github.com/googlecast/&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;receiver&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
由於2048遊戲部分不太需要去寫邏輯部分，故主要只要處理訊息的接收與發出即可&lt;/div&gt;
&lt;div&gt;
初始化部分:&lt;/div&gt;
&lt;div&gt;
在 application.js 中 window.requestAnimationFrame中加入&lt;/div&gt;
&lt;div&gt;
&lt;script src=&quot;https://gist.github.com/hsienwei/17a58ee1f2e1ba5ac479.js&quot;&gt;&lt;/script&gt;&lt;/div&gt;
&lt;div&gt;
這裡我有一個部分是用偷懶的做法&lt;/div&gt;
&lt;div&gt;
window.senderId=event.senderId; 這裡將senderId放在window底下以便之後要回傳訊息使用&lt;/div&gt;
&lt;div&gt;
但個人覺得不是好的做法 但這是測試用的程式就先略過&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
鍵盤事件接收部分 &amp;nbsp;在 keyboard_input_manager.js 中的KeyboardInputManager.prototype.listen方法中加入&lt;/div&gt;
&lt;div&gt;
&lt;script src=&quot;https://gist.github.com/hsienwei/f7b4ba0b553e94195617.js&quot;&gt;&lt;/script&gt;&lt;/div&gt;
&lt;div&gt;
將sender傳送過來的訊息對應該做的行為&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
當玩家無法再移動或者是已達到2048的時候都會有訊息出現，在這種狀況下可以回傳訊息給sender出現相對應的操作界面，為此修改html_actuator.js如下&lt;/div&gt;
&lt;div&gt;
&lt;script src=&quot;https://gist.github.com/hsienwei/b232fa188603c7b928ac.js&quot;&gt;&lt;/script&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;sender&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
這裡我做了兩個平台的sender程式，其實主要也是改google的範例程式&lt;/div&gt;
&lt;div&gt;
chrome版主要就是把keyboard event send給receiver&lt;/div&gt;
&lt;div&gt;
android也是差不多, 只是把swipe的方向改為對應的key code傳給receiver&lt;/div&gt;
&lt;div&gt;
另外接收遊戲結束的訊息跳出對應的AlertDialog&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
或許下次可以試試看現有 html5遊戲引擎在chromecast上的效能&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;hr /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
以下為參考資料&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;模擬器&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
模擬器感覺在自定receiver app的部分支援並不完整 &amp;nbsp;實機測還是比較好&lt;/div&gt;
&lt;div&gt;
以下是目前有看到的模擬器&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
CR Cast (chrome 擴展)&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://chrome.google.com/webstore/detail/cr-cast/acmfmindblghbicdipoakcolegkcddbk&quot;&gt;https://chrome.google.com/webstore/detail/cr-cast/acmfmindblghbicdipoakcolegkcddbk&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
Leapcast (python, run on chrome)&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://github.com/dz0ny/leapcast&quot;&gt;https://github.com/dz0ny/leapcast&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
android 模擬 &amp;nbsp;cheapcast (跑不起來)&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://github.com/mauimauer/cheapcast&quot;&gt;https://github.com/mauimauer/cheapcast&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
rPlay on iOS&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://www.vmlite.com/index.php?option=com_kunena&amp;amp;Itemid=158&amp;amp;func=view&amp;amp;catid=23&amp;amp;id=12020&quot;&gt;http://www.vmlite.com/index.php?option=com_kunena&amp;amp;Itemid=158&amp;amp;func=view&amp;amp;catid=23&amp;amp;id=12020&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Developer Console&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://cast.google.com/publish/&quot;&gt;https://cast.google.com/publish/&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
由於要自行開發receiver app所以需要開通Developer Console &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
需要五元美金 &amp;nbsp;如果只是要cast媒體就不需要&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7TojWQ64LJE18RCe4VEpLVY7Fwla2dImZjRjb449BITGxKAoWXahXKvRHPNh3ISTEpAfdkKfsEauSAyKVAbnhR4Z_FfpgE5554k9Vh6X7u4VA1vjzI6sRKN0zV6TGtEEnSwSH/s1600/b72bd572e2b53f51aa8b95cf1aea2f29-763923.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7TojWQ64LJE18RCe4VEpLVY7Fwla2dImZjRjb449BITGxKAoWXahXKvRHPNh3ISTEpAfdkKfsEauSAyKVAbnhR4Z_FfpgE5554k9Vh6X7u4VA1vjzI6sRKN0zV6TGtEEnSwSH/s320/b72bd572e2b53f51aa8b95cf1aea2f29-763923.png&quot; id=&quot;BLOGGER_PHOTO_ID_6014969691270461042&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
如圖，可以設置APP 與 測試用裝置&lt;/div&gt;
&lt;div&gt;
如果Application不是Published的話則要有輸入的裝置才能使用&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;目前已有的遊戲應用&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
下面有兩個已在 Google Play上架的應用&lt;/div&gt;
&lt;div&gt;
GamingCast (for Chromecast)&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://play.google.com/store/apps/details?id=co.essh.gamecast&quot;&gt;https://play.google.com/store/apps/details?id=co.essh.gamecast&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
2048 Chromecast&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://play.google.com/store/apps/details?id=com.sunnydev.cast2048&quot;&gt;https://play.google.com/store/apps/details?id=com.sunnydev.cast2048&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-top: 1px solid #d3d3d3; margin-bottom: 16px; margin-top: 32px; padding-top: 16px; width: 100%px;&quot;&gt;    &lt;tbody&gt;
&lt;tr&gt;     &lt;td style=&quot;color: #747474; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px; text-align: left;&quot;&gt;Evernote 幫您記住生活的點點滴滴，輕鬆保持條理。&lt;a href=&quot;https://www.evernote.com/getit?email_name=emailNote&amp;amp;email_guid=900f7ffb-54ae-4176-95ff-3c1015f04844&amp;amp;email_link=download_app&quot; style=&quot;color: #5fb336; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;下載 Evernote&lt;/a&gt;。     &lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/7497032620455867786/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/7497032620455867786' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/7497032620455867786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/7497032620455867786'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2014/05/2048-for-chromecast_19.html' title='自製2048 for Chromecast'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7TojWQ64LJE18RCe4VEpLVY7Fwla2dImZjRjb449BITGxKAoWXahXKvRHPNh3ISTEpAfdkKfsEauSAyKVAbnhR4Z_FfpgE5554k9Vh6X7u4VA1vjzI6sRKN0zV6TGtEEnSwSH/s72-c/b72bd572e2b53f51aa8b95cf1aea2f29-763923.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-1915873672287675606</id><published>2014-04-08T18:43:00.001+08:00</published><updated>2014-04-08T18:45:28.949+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Facebook"/><category scheme="http://www.blogger.com/atom/ns#" term="ios"/><title type='text'>Facebook comments 是否能在iOS用原生UI製作</title><content type='html'>&lt;span style=&quot;font-family: Arial; font-size: x-small;&quot;&gt;這裡指的是social plugin中的comments&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: x-small;&quot;&gt;&lt;a href=&quot;https://developers.facebook.com/docs/plugins/comments/&quot;&gt;https://developers.facebook.com/docs/plugins/comments/&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;如果你不要add comment的話應該是做的到的&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;本次專案中有一個功能是可以對某個頁面做FB comment&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;在網頁中可以用Facebook的plugin&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;但在app當中SDK沒有提供相關的UI可供使用&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;要使用的話必須用UIWebView加上plugin來達成&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;後來在Facebook的graph api當中找到有關的功能&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #042eee; font-family: Arial; font-size: 13px;&quot;&gt;&lt;u&gt;https://developers.facebook.com/docs/graph-api/reference/object/comments/&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;裡面有提到Reading與Publishing的功能&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;但由於我使用的ID是網頁網址所以必須改一下&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;[FBRequestConnection startWithGraphPath:@“/****** id *******/comments&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;[FBRequestConnection startWithGraphPath:@&quot;/comments/?ids=http://www.xxx.xxx.xx”&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;在Reading的部分沒有問題，但在Publishing的部分就會收到錯誤訊息&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;body =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; error =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; code = 100;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; message = &quot;(#100) Comments may not be added to a comment plugin&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type = OAuthException;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;後來仔細查一下&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;發現原來這個功能是不能使用的&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;相關連結：&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #042eee; font-family: Arial; font-size: 13px;&quot;&gt;&lt;u&gt;http://stackoverflow.com/questions/16810596/post-comment-via-graph-api-to-social-plugin-box&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #042eee; font-family: Arial; font-size: 13px;&quot;&gt;&lt;u&gt;http://stackoverflow.com/questions/5673821/can-you-write-using-facebook-graph-api-to-a-web-sites-facebook-comment-module&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #042eee; font-family: Arial; font-size: 13px;&quot;&gt;&lt;u&gt;https://developers.facebook.com/bugs/164794086987157&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;既然都提供了，為何不能使用呢，真猜不透啊&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/1915873672287675606/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/1915873672287675606' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/1915873672287675606'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/1915873672287675606'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2014/04/facebook-comments-iosui.html' title='Facebook comments 是否能在iOS用原生UI製作'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-5456101718316213829</id><published>2014-04-07T23:02:00.003+08:00</published><updated>2014-09-19T15:02:53.854+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ios"/><category scheme="http://www.blogger.com/atom/ns#" term="youtube"/><title type='text'>iOS中播放youtube影片經驗</title><content type='html'>&lt;div class=&quot;ennote&quot; style=&quot;-webkit-line-break: after-white-space; -webkit-nbsp-mode: space; word-wrap: break-word;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;iOS不像android一樣有提供youtube的API，要播放youtube影片需要使用UIWebView + youtube iframe api&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;font-size: 14px;&quot;&gt;使用iframe api&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&quot;the current best practice for embedding YouTube videos in an iOS application is to use the&amp;nbsp;&lt;a href=&quot;https://developers.google.com/youtube/iframe_api_reference&quot;&gt;YouTube iframe Player&lt;/a&gt;&amp;nbsp;within a&amp;nbsp;&lt;a href=&quot;https://developer.apple.com/library/ios/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html&quot;&gt;UIWebView container&lt;/a&gt;.&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;所以基本上這個方法應該是最好的方法，但由於使用iframe需要寫javascript，一開始因為我懶的關係，所以我先試過一些其他的程式庫，但我最後放棄了（見最後一段）&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://developers.google.com/youtube/iframe_api_reference?hl=zh-TW&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;https://developers.google.com/youtube/iframe_api_reference?hl=zh-TW&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;這裡面提供了相關API資訊&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;個人寫的讀取用js code&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&quot;brush: js; html-script: true&quot;&gt;    &lt;script src=&quot;http://www.youtube.com/iframe_api&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player(&#39;player&#39;, {
          width: &#39;%d&#39;,
          height: &#39;%d&#39;,
          videoId: &#39;%@&#39;,
          events: {
            &#39;onReady&#39;: onPlayerReady,
            &#39;onStateChange&#39;: onPlayerStateChange
          },
          playerVars: {
            &#39;playsinline&#39;:&#39;%d&#39;,
            &#39;controls&#39;:&#39;1&#39;,
          }
        });
      }
      function onPlayerReady(event) {
        window.location = &#39;js-call://youtubeStart&#39;;
        event.target.playVideo();
      }
      function onPlayerStateChange(event) {
        if(event.data == YT.PlayerState.ENDED)
        {
          window.location = &#39;js-call://youtubeEnd&#39;;
        }
      }
    &lt;/script&gt;
&lt;/pre&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;由於autoplay參數無法用在mobile裝置, 所以如果要讀取自動播放就要在onPlayerReady中來做&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;可以在onPlayerStateChange中取YT.PlayerState.ENDED事件來知道影片播放完畢&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;playerVars的playsinline是說播放時是要在指定範圍內還是要全螢幕播放(後來再是似乎已無用)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;window.location = &#39;js-call://xxxxxx&#39; 可在UIWebViewDelegate shouldStartLoadWithRequest中接收並處理&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b style=&quot;font-size: 14px;&quot;&gt;偷吃步 api&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;iOS 8 已無法使用&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;由於沒有提供API供使用，所以有些事件是取不到的，像是進入全螢幕以及離開全螢幕的事件，由於一般使用MPMoviePlayerController都是有notification可以使用，如MPMoviePlayerWillEnterFullscreenNotification以及MPMoviePlayerWillExitFullscreenNotification，但經由UIWebViewController播放的影片並不會有這兩個事件發生，故在這裡必須要用私有API，會有被reject的風險，但值得試試看&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/8518719/how-to-receive-nsnotifications-from-uiwebview-embedded-youtube-video-playback&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;http://stackoverflow.com/questions/8518719/how-to-receive-nsnotifications-from-uiwebview-embedded-youtube-video-playback&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;b&gt;取得UIMoviePlayerController&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;除了事件取不到以外，也沒有辦法可以以程式去控制是否為全螢幕，由於知道底層仍然是使用UIMoviePlayerController，所以如果可以取得到的話就可以使用setFullscreen方法來控制&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://gist.github.com/romainbriche/2308668&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;https://gist.github.com/romainbriche/2308668&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;這個連結提供一個做法去取得該物件，但其實我試了似乎沒效，但可以發現到裡面有FigPluginView的存在（詳細請見下一段），查找資料確認仍有UIMoviePlayerController在其中只是沒有提供方法取用，後來找到一個可行的做法就是藉由NSNotification的callback method來取得&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;-(void) myMovieEnterFullScreen: (NSNotification*) aNotification&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; moviePlayer = aNotification.object;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;. . .&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;當然這樣做還是得要用到上一段說到的私有API&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;b&gt;quick time plugin 與 player controller&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;上一段當中有提到我在UIWebView當中找到一個FigPluginView的存在&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;這個物件與UIWebView,&amp;nbsp;MPMoviePlayerController的關係可見以下連結&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://blog.csdn.net/hursing/article/details/8896170&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;http://blog.csdn.net/hursing/article/details/8896170&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;詳細說明了播放youtube影片的底層還是使用MPMoviePlayerController&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;font-size: 14px;&quot;&gt;曾試用過的library&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;a href=&quot;https://github.com/hellozimi/HCYoutubeParser&quot;&gt;HCYoutubeParser&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;一開始可以用, 它的作用是幫你抓出youtube實際的播放串流URL，剛開始的時候採用(2月初)，但大約3月時發現不能用了，似乎是資料格式有變動，由於這方面我並不熟所以放棄使用&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://github.com/0xced/XCDYouTubeVideoPlayerViewController&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;XCDYouTubeVideoPlayerViewController&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;原理同上，一開始就不能用&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://github.com/AdamRobertsEF/UIWebView-YouTube--iOS-Category--ARC-compliant-code&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;UIWebView-YouTube--iOS-Category--ARC-compliant-code&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;幫UIWebView加上Category讓你方便播放，但只有陽春功能且非使用iframe故放棄&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;20140502&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;UIWebView的相關設定&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;








&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;mediaPlaybackRequiresUserAction --- 是否可自動播放或經用戶控制&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;allowsInlineMediaPlayback --- 是否可以inline&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;mediaPlaybackAllowsAirPlay --- 是否有airplay功能&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;b&gt;inline的播放行為&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;經測試如果inline時點擊播放會自動全螢幕播放&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;但如果使用js呼叫player.playVideo()則不會變成全螢幕&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-top: 1px solid #d3d3d3; margin-bottom: 16px; margin-top: 32px; padding-top: 16px; width: 100%px;&quot;&gt;    &lt;tbody&gt;
&lt;tr&gt;     &lt;td style=&quot;color: #747474; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px; text-align: left;&quot;&gt;Evernote 幫您記住生活的點點滴滴，輕鬆保持條理。&lt;a href=&quot;https://www.evernote.com/getit?email_name=emailNote&amp;amp;email_guid=1f4bcebe-7362-4e54-8e17-bbe0f879741f&amp;amp;email_link=download_app&quot; style=&quot;color: #5fb336; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;下載 Evernote&lt;/a&gt;。     &lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/5456101718316213829/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/5456101718316213829' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/5456101718316213829'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/5456101718316213829'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2014/04/iosyoutube.html' title='iOS中播放youtube影片經驗'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-804715637825448963</id><published>2013-12-30T19:24:00.000+08:00</published><updated>2013-12-30T19:25:31.649+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cocos2d-x"/><category scheme="http://www.blogger.com/atom/ns#" term="glsl"/><category scheme="http://www.blogger.com/atom/ns#" term="shader"/><title type='text'>使用cocos2d-x實作Post Processing</title><content type='html'>&lt;div class=&quot;ennote&quot; style=&quot;-webkit-line-break: after-white-space; -webkit-nbsp-mode: space; word-wrap: break-word;&quot;&gt;
&lt;div&gt;
上次做了一些想做的shader效果&lt;/div&gt;
&lt;div&gt;
這次主要研究在cocos2d-x上如何實現Post Processing&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
主要的參考資料如下&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://en.wikibooks.org/wiki/OpenGL_Programming/Post-Processing&quot;&gt;http://en.wikibooks.org/wiki/OpenGL_Programming/Post-Processing&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
裡面主要以OpenGL語法來製作，大概步驟如下&lt;/div&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;建立texture&lt;/li&gt;
&lt;li&gt;建立post processing用的framebuffer&lt;/li&gt;
&lt;li&gt;將步驟2的framebuffer作為步驟1的texture資料&lt;/li&gt;
&lt;li&gt;在post processign framebuffer上繪圖&lt;/li&gt;
&lt;li&gt;將步驟1的texture搭配post processing shader繪圖出來&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
在cocos2d-x中，因為有提供RenderTexture類別，所以我們可以不用處理那麼多步驟。&lt;/div&gt;
&lt;div&gt;
基本上只要建立起RenderTexture，就可以用getSprite()-&amp;gt;getTexture()來取得與步驟1~3相同效果的texture。&lt;/div&gt;
&lt;div&gt;
步驟4則可以藉由在RenderTexture的begin()與end()中加入要繪圖的物件的visit()來達到。&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
而步驟5則只要將取出的texture用來建立新的sprite，並在該sprite上加上shader就可以了。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
下圖為使用cocos2d-x實作上面連結的效果&lt;/div&gt;
&lt;div&gt;
右下有按鈕可以切換是否使用Post Processing&lt;/div&gt;
&lt;div&gt;
程式一樣放在&lt;a href=&quot;https://github.com/hsienwei/shader_cocos2dx&quot;&gt;https://github.com/hsienwei/shader_cocos2dx&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJJCvj8ezjBI7jlYv_so6OekzbTxxJwDiLMUwn8La1h047rhoYziM_RNCIkUqRWkpbhBNAD_hada5CsGkcHV7ljdnHmilLWMfGNSDJJbuMAuwHH33BSwIhHpyDYR1wSiPEGvI1/s1600/8d4c01cfc307b393ca40c23c7a8ae7eb-711292.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJJCvj8ezjBI7jlYv_so6OekzbTxxJwDiLMUwn8La1h047rhoYziM_RNCIkUqRWkpbhBNAD_hada5CsGkcHV7ljdnHmilLWMfGNSDJJbuMAuwHH33BSwIhHpyDYR1wSiPEGvI1/s320/8d4c01cfc307b393ca40c23c7a8ae7eb-711292.png&quot; id=&quot;BLOGGER_PHOTO_ID_5963143813162686386&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/804715637825448963/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/804715637825448963' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/804715637825448963'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/804715637825448963'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/12/cocos2d-xpost-processing.html' title='使用cocos2d-x實作Post Processing'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJJCvj8ezjBI7jlYv_so6OekzbTxxJwDiLMUwn8La1h047rhoYziM_RNCIkUqRWkpbhBNAD_hada5CsGkcHV7ljdnHmilLWMfGNSDJJbuMAuwHH33BSwIhHpyDYR1wSiPEGvI1/s72-c/8d4c01cfc307b393ca40c23c7a8ae7eb-711292.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-754341933876684541</id><published>2013-12-26T01:11:00.000+08:00</published><updated>2013-12-26T01:11:34.263+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cocos2d-x"/><category scheme="http://www.blogger.com/atom/ns#" term="glsl"/><category scheme="http://www.blogger.com/atom/ns#" term="shader"/><title type='text'>cocos2d-x中實作幾個shader效果</title><content type='html'>&lt;div class=&quot;ennote&quot; style=&quot;-webkit-line-break: after-white-space; -webkit-nbsp-mode: space; word-wrap: break-word;&quot;&gt;
&lt;div&gt;
在之前的專案中有機會使用shader實做了mask效果&lt;/div&gt;
&lt;div&gt;
這次將之前曾經想要做但是專案不願意給時間嘗試的做法試著做出來&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
清單如下&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;圖片轉灰階&lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cocos2d-x中，sprite的setColor在設定顏色後基本上還是留有本來圖片跟設定顏色混合而已，這個做法是單純的轉灰階&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;圖片加邊框&lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 有一次專案的需求是希望可以幫圖片在邊緣加上指定顏色的邊框，後來的作法是另外提供圖片，但如果有20張圖有這個需求就需要額外作20張圖，用shader就比較省事&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;全畫面遮罩&lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 另一次專案的需求是希望玩家可以專注於某個功能的使用，想要將其他部分打暗只留該功能按鈕的部分是亮的；這裡使用layer製作，可以自行指定focus的位置&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;背景填滿&lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 之前在做背景時都用sprite去拼，實際上物件很多，且容易造成有接縫，如果要移動也麻煩，用shader還滿方便，一樣是用layer去做&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div&gt;
範例程式　&lt;a href=&quot;https://github.com/hsienwei/shader_cocos2dx&quot;&gt;https://github.com/hsienwei/shader_cocos2dx&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
目前只有在win32版跑過&lt;/div&gt;
&lt;div&gt;
用的是vs2013&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuWb6G2TLIQRUAR6L-Mrkf0v627vU0pAEN_yL4uHgrfKoSM_Xk4QmrojqoQ0IoGpIA-6HVp2jNsmf1C0RBbz5DdEGnCzoJK4ZYxMh9NTJpV0zdxRUBeponCpI_b4lu7bideCkM/s1600/155f32e74ff77a330cf0c5528140a0c3-785658.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuWb6G2TLIQRUAR6L-Mrkf0v627vU0pAEN_yL4uHgrfKoSM_Xk4QmrojqoQ0IoGpIA-6HVp2jNsmf1C0RBbz5DdEGnCzoJK4ZYxMh9NTJpV0zdxRUBeponCpI_b4lu7bideCkM/s320/155f32e74ff77a330cf0c5528140a0c3-785658.png&quot; id=&quot;BLOGGER_PHOTO_ID_5961377611610755026&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/754341933876684541/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/754341933876684541' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/754341933876684541'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/754341933876684541'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/12/cocos2d-xshader.html' title='cocos2d-x中實作幾個shader效果'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuWb6G2TLIQRUAR6L-Mrkf0v627vU0pAEN_yL4uHgrfKoSM_Xk4QmrojqoQ0IoGpIA-6HVp2jNsmf1C0RBbz5DdEGnCzoJK4ZYxMh9NTJpV0zdxRUBeponCpI_b4lu7bideCkM/s72-c/155f32e74ff77a330cf0c5528140a0c3-785658.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-7357799609885445861</id><published>2013-12-09T00:43:00.001+08:00</published><updated>2013-12-09T00:44:20.970+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Html5"/><title type='text'>使用HTML5製作投影片</title><content type='html'>由於最近面試有一間公司需要你用投影片去展示一下過去的經歷&lt;br /&gt;
看了他的工作需求有對HTML5/CSS3等熟悉的條件&lt;br /&gt;
雖然我不是很熟但想說如果用個有關係的做法來呈現也是不錯&lt;br /&gt;
（後來發現不是必要）&lt;br /&gt;
查了一下後決定用HTML5來做投影片&lt;br /&gt;
看到下面的網站&lt;br /&gt;
&lt;a href=&quot;http://www.sitepoint.com/5-free-html5-presentation-systems/&quot;&gt;http://www.sitepoint.com/5-free-html5-presentation-systems/&lt;/a&gt;&lt;br /&gt;
裡面有介紹五個演示系統&lt;br /&gt;
後來我決定用&lt;a href=&quot;https://github.com/hakimel/reveal.js&quot;&gt;reveal.js&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
成果如下&lt;br /&gt;
&lt;a href=&quot;https://dl.dropboxusercontent.com/u/10581994/reveal.js-master/cv.html&quot;&gt;https://dl.dropboxusercontent.com/u/10581994/reveal.js-master/cv.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
我覺得它有快速鍵可以用&lt;br /&gt;
esc可以看全部投影片&lt;br /&gt;
f可以切換全螢幕&lt;br /&gt;
還有轉換成pdf的功能十分不錯&lt;br /&gt;
有需要的可以用一下&lt;br /&gt;
&lt;br /&gt;
唯獨預設的文字感覺較適合英文&lt;br /&gt;
如果要用在中文上需要在css中修改一下&lt;br /&gt;
像我是加上黑體來用&lt;br /&gt;
另外如果是舊一點的電腦換頁動畫可能會有一點delay的狀況</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/7357799609885445861/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/7357799609885445861' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/7357799609885445861'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/7357799609885445861'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/12/html5.html' title='使用HTML5製作投影片'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-5797799339722971677</id><published>2013-11-14T15:45:00.001+08:00</published><updated>2014-01-16T01:11:52.936+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cocos2d-x"/><category scheme="http://www.blogger.com/atom/ns#" term="Html5"/><title type='text'>45度角地圖 Z-Sort 實作</title><content type='html'>Demo：&lt;a href=&quot;https://dl.dropboxusercontent.com/u/10581994/ZSortTest/index.html&quot;&gt;https://dl.dropboxusercontent.com/u/10581994/ZSortTest/index.html&lt;/a&gt;&lt;br /&gt;
Github：&lt;a href=&quot;https://github.com/hsienwei/zSort_cocos2dx_html5&quot;&gt;https://github.com/hsienwei/zSort_cocos2dx_html5&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
2014/01/16：cocos2d-x 2.2.2已修正此問題&lt;br /&gt;
2013/11/24 : 目前在chrome中會無法顯示(火狐可以), 為&lt;a href=&quot;http://www.cocos2d-x.org/forums/19/topics/39063&quot;&gt;cocos2d-x html5的bug&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
這個專案主要是以cocos2d-x html5版本來實作一個我之前在工作中使用的45度角地圖Z-Sort演算法，一來練習cocos2d-x html5，一來為之前的工作內容做一個記錄。&lt;br /&gt;
&lt;br /&gt;
開啟後一開始的狀況是沒有使用演算法排序的狀況，單純依照加入的順序去排序，按下&quot;Sort&quot;後就會依照演算法的結果為各個Sprite設定Z值。&lt;br /&gt;
&lt;br /&gt;
當初主要導入這個做法的是我同事，我只是後來有在稍微修改&lt;br /&gt;
演算法參考網頁：&lt;a href=&quot;http://wgcode.iteye.com/blog/847695&quot;&gt;http://wgcode.iteye.com/blog/847695&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Sprite沒有使用圖，直接用drawingUtil來繪圖，發現用手機來看的話線條會沒辦法出來，也許是一個bug，也有可能是因為手機部分還沒有完善。&lt;br /&gt;
&lt;br /&gt;
另外在點擊事件上也有一點問題，導致必須做很多處理才能達到縮放後也可以正確點擊，不確定這是我的用法錯誤還是這部分本身還不完整，可參照&amp;nbsp;&lt;a href=&quot;https://github.com/hsienwei/zSort_cocos2dx_html5/blob/master/src/myApp.js&quot;&gt;https://github.com/hsienwei/zSort_cocos2dx_html5/blob/master/src/myApp.js&lt;/a&gt;&amp;nbsp; &amp;nbsp;Line 53</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/5797799339722971677/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/5797799339722971677' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/5797799339722971677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/5797799339722971677'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/11/45-z-sort.html' title='45度角地圖 Z-Sort 實作'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-7956753468405569178</id><published>2013-11-13T22:02:00.000+08:00</published><updated>2013-11-13T22:06:54.834+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Unity"/><title type='text'>Unity練習：夜市彈珠台</title><content type='html'>Demo：&lt;a href=&quot;https://dl.dropboxusercontent.com/u/10581994/pinball/pinball.html&quot;&gt;https://dl.dropboxusercontent.com/u/10581994/pinball/pinball.html&lt;/a&gt;&lt;br /&gt;
Github：&lt;a href=&quot;https://github.com/hsienwei/pinball_unity&quot;&gt;https://github.com/hsienwei/pinball_unity&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
玩法就是按一下滑鼠左鍵放球，再按著滑鼠左鍵蓄力，放開後發射，當球都打完後按一下滑鼠左鍵會讓球掉到下面重來。&lt;br /&gt;
&lt;br /&gt;
感覺上沒有花太多時間在寫程式，反而弄Model跟動作的處理比較花時間。&lt;br /&gt;
&lt;br /&gt;
物理部分就完全用Unity內建的功能，主要只有調整Physic material來做到彈珠打到釘子會有彈回的效果，另外有將Time.fixedDeltaTime調小，不然速度快的時候球會飛出去，或者物理的行為不精準。&lt;br /&gt;
&lt;br /&gt;
動作部分，球台下面的檔板基本上使用3ds Max中作的動畫，發射的動畫本來也是要用3ds Max來做，但是由於放到Unity中位置會跑掉，所以後來直接用Unity的Animation來處理。&lt;br /&gt;
&lt;br /&gt;
Shader部分由於本來美術就不是專長，所以直接用一個內建的shader；另外沒有2D介面，之後再來試試看4.3的2D功能。</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/7956753468405569178/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/7956753468405569178' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/7956753468405569178'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/7956753468405569178'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/11/unity.html' title='Unity練習：夜市彈珠台'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-3079266893340266528</id><published>2013-10-02T21:31:00.002+08:00</published><updated>2013-12-26T01:13:10.500+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cocos2d-x"/><category scheme="http://www.blogger.com/atom/ns#" term="glsl"/><category scheme="http://www.blogger.com/atom/ns#" term="shader"/><title type='text'>cocos2d-x mask 作法嘗試</title><content type='html'>這裡指的mask是說一張圖但我要將指定一部分挖掉這樣，我在做的時候都是以一張圖為主圖，另一張mask圖以alpha值指定要挖空的地方&lt;br /&gt;
&lt;br /&gt;
目前有試過兩種做法&lt;br /&gt;
1. RenderTexture&amp;nbsp;+ BlendFunc&lt;br /&gt;
大概程式碼如下&lt;br /&gt;
&lt;pre class=&quot;brush: text&quot;&gt;CCSprite* createMaskSprite()
{
    cocos2d::ccBlendFunc bf;
    bf.src = GL_DST_ALPHA;//GL_ONE_MINUS_DST_ALPHA;
    bf.dst = GL_ZERO;

    CCSprite* selfSprite = /*主圖的sprite*/;
    CCSprite* maskSprite = /*mask圖的sprite*/;
    selfSprite-&amp;gt;setPosition(ccp(selfSprite-&amp;gt;getContentSize().width/2, selfSprite-&amp;gt;getContentSize().height/2));
    maskSprite-&amp;gt;setPosition(ccp(maskSprite-&amp;gt;getContentSize().width/2, maskSprite-&amp;gt;getContentSize().height/2));
    
    selfSprite-&amp;gt;setBlendFunc(bf);
    
    CCRenderTexture *rt = CCRenderTexture::create((int)selfSprite-&amp;gt;getContentSize().width, (int)selfSprite-&amp;gt;getContentSize().height);
    rt-&amp;gt;beginWithClear(0, 0, 0, 0);
    maskSprite-&amp;gt;visit();
    selfSprite-&amp;gt;visit();
    rt-&amp;gt;end();
    
    CCSprite *retval = CCSprite::createWithTexture(rt-&amp;gt;getSprite()-&amp;gt;getTexture());
    retval-&amp;gt;getTexture()-&amp;gt;setAntiAliasTexParameters();
    retval-&amp;gt;setFlipY(true);
    
    return retval;
}
&lt;/pre&gt;
&lt;br /&gt;
主要是使用BlendFunc的方法，在RenderTexture畫出想要的效果之後再使用，但如果只直接用BlendFunc可能會被其他的sprite影響產不出想要的效果
&lt;br /&gt;
&lt;br /&gt;
2. Shader
&lt;br /&gt;
Shader程式碼處理起來比較麻煩，建議看cocos2d-x範例程式的shader部分&lt;br /&gt;
下面是我寫的一個小範例&lt;br /&gt;
&lt;a href=&quot;https://github.com/hsienwei/shader_cocos2dx&quot;&gt;https://github.com/hsienwei/shader_cocos2dx&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
cocos2d-x的部分主要是參考範例程式改的&lt;br /&gt;
重要的是shader部分&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: text&quot;&gt;#ifdef GL_ES
precision mediump float;
#endif

varying vec4 v_fragmentColor;
varying vec2 v_texCoord;

uniform sampler2D u_texture;
uniform sampler2D u_mask;

void main() {
    vec4 mainColor = texture2D(u_texture, v_texCoord);
    vec4 maskColor = texture2D(u_mask, v_texCoord);
    vec4 srcColor = vec4(mainColor.r * maskColor.a,
                         mainColor.g * maskColor.a,
                         mainColor.b * maskColor.a,
                         mainColor.a * maskColor.a);
    
    gl_FragColor = srcColor;
}
&lt;/pre&gt;
將主圖的rgba值都乘以mask圖的alpha值即可，要達到這個效果只要動Fragment Shader即可&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/3079266893340266528/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/3079266893340266528' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/3079266893340266528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/3079266893340266528'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/10/cocos2d-x.html' title='cocos2d-x mask 作法嘗試'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-6336272534231069702</id><published>2013-10-01T13:19:00.000+08:00</published><updated>2013-10-01T13:20:33.493+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>剖析HTML資料轉為JSON</title><content type='html'>之前有一陣子很迷Puzzle &amp;amp; Dragon，所以常常查閱&lt;a href=&quot;http://zh.pad.wikia.com/wiki/&quot;&gt;http://zh.pad.wikia.com/wiki/&lt;/a&gt;&amp;nbsp;這個wiki網站，有一次用手機查的時候感覺他的手機板介面不太方便，而且如果可以用該資料為基礎讓手機通知我事件發生似乎不錯，所以就開始寫一個parser來處理網頁資料，把&quot;緊急／降臨時間表&quot;與&quot;活動時間表&quot;取需要的資料處理為JSON格式。&lt;br /&gt;
&lt;div class=&quot;ennote&quot; style=&quot;-webkit-line-break: after-white-space; -webkit-nbsp-mode: space; word-wrap: break-word;&quot;&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
結果大概如下：&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://gcmtesthhhw.appspot.com/WikiData&quot;&gt;http://gcmtesthhhw.appspot.com/WikiData&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
那時候的大概想法是這樣:&lt;/div&gt;
&lt;div&gt;
用server跑一個排程，定時更新資料並用手機去取用。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Server端主要使用GAE，主要原因在我對server管理沒有經驗，用GAE我可以跳過server設定這一塊，Java基本上也是很熟了，所以寫起來沒啥問題，只是要了解一下CRON的排程設定。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
剖析程式庫那時候選擇了&lt;a href=&quot;http://jsoup.org/&quot;&gt;http://jsoup.org/&lt;/a&gt;，使用上並不難，基本上就是實作&lt;a href=&quot;http://jsoup.org/apidocs/org/jsoup/select/NodeVisitor.html&quot;&gt;NodeVisitor&lt;/a&gt;，然後使用head與tail方法的Node參數來判斷要取的資料，只是那時候有無法取執行javascript的問題，所幸影響不大，所以基本上就是取網頁程式碼，曾經有試過用&lt;a href=&quot;http://htmlunit.sourceforge.net/&quot;&gt;JavaUnit&lt;/a&gt;想要取執行完javascript的網頁但還是失敗，所以這部分我後來就沒處理，JSON部分就直接用Java的JSONObject即可。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
另外一個問題就是由於wiki資料由眾人維護，沒有一個既定格式，常常會有變更；取資料也不方便，沒有類似id的東西可以辨識，最後只好用標題來找，再取相對應的結構部分。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
最後因為專案太趕就沒時間再進行，後來再去查已經有人出了一個相似但各方面都比較好用的APP，似乎沒有做的必要了。&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/6336272534231069702/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/6336272534231069702' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/6336272534231069702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/6336272534231069702'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/10/htmljson.html' title='剖析HTML資料轉為JSON'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-8298689750871451951</id><published>2013-08-21T15:51:00.002+08:00</published><updated>2013-08-21T15:52:21.476+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cocos2d-x"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="link"/><title type='text'>John Resig&#39;s Javascript inheritance</title><content type='html'>&lt;br /&gt;
在上UDACity的HTML5 Game dev以及在看cocos2d-x HTML5時都看的到的一個東西&lt;br /&gt;
John Resig的 Javascript inheritance連結&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #484848; font-family: Verdana, sans-serif; font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;a href=&quot;http://ejohn.org/blog/simple-javascript-inheritance/&quot;&gt;http://ejohn.org/blog/simple-javascript-inheritance/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
javascript本身沒有繼承的概念&lt;br /&gt;
使用這樣的pattern可以取得類似的效果</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/8298689750871451951/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/8298689750871451951' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/8298689750871451951'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/8298689750871451951'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/08/udacityhtml5-game-devcocos2d-x-html5.html' title='John Resig&#39;s Javascript inheritance'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-4122034250602042180</id><published>2013-08-19T12:53:00.002+08:00</published><updated>2013-08-19T12:53:09.280+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="link"/><title type='text'>解決mac上adb找不到小米機問題</title><content type='html'>找到的資料上寫的很清楚&lt;br /&gt;
&lt;br /&gt;
原連結&lt;br /&gt;
&lt;a href=&quot;http://my.eoe.cn/iceskysl/archive/4377.html&quot;&gt;http://my.eoe.cn/iceskysl/archive/4377.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
evernote備份&lt;br /&gt;
&lt;a href=&quot;http://www.evernote.com/shard/s54/sh/6388b274-4256-4167-8036-b9d2d4c32a73/41f4d05cc192f21278d5740754eae649&quot;&gt;http://www.evernote.com/shard/s54/sh/6388b274-4256-4167-8036-b9d2d4c32a73/41f4d05cc192f21278d5740754eae649&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/4122034250602042180/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/4122034250602042180' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/4122034250602042180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/4122034250602042180'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/08/macadb.html' title='解決mac上adb找不到小米機問題'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-1176965411090107159</id><published>2013-08-15T23:45:00.001+08:00</published><updated>2013-08-15T23:56:40.022+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="ant"/><category scheme="http://www.blogger.com/atom/ns#" term="cocos2d-x"/><title type='text'>使用ant編譯apk檔</title><content type='html'>&lt;div class=&quot;ennote&quot; style=&quot;-webkit-line-break: after-white-space; -webkit-nbsp-mode: space; word-wrap: break-word;&quot;&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
在一般的狀況下最為人所知產出apk的方法是使用ADT eclipse plugin功能來產出APK檔&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
(Android Tools-&amp;gt;Export Signed/Unsigned Application Package)&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
但除此之外android也提供開發者經由ant產出apk檔&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
mac中有內建ant&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
所以可以在mac的終端機下指令來產出apk檔&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
那為何要使用ant&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
如果今天要產出多種版本 你必須要打開你的eclipse分別打開多個專案然後Export Signed/Unsigned Application Package&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
等於同樣步驟要作三次&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
而且還需要輸入密碼&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
而且你必須待在電腦旁邊&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
如果今天用ant來編的話 &amp;nbsp;你可以指定一次編多種版本 &amp;nbsp;也不用在輸入任何東西(前提是有寫到設定檔)&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
像我之前有產出10個檔案的需求(五個market api * 2(debug/release))&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
通常都要離開公司時執行&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
隔天就可以寄出檔案了&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
以下寫一些在cocos2d-x中使用ant的經驗&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
使用cocos2d-x建立的android專案中&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
會比一般的android project多出以下的檔案&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
build.xml - ant使用的專案設置&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
local.properties - 裡面會有sdk的路徑設定值&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
ant.properties - 預設是空的 &amp;nbsp;但可以在這裡設置編apk檔時使用的key相關設定&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;div&gt;
要注意的是如果你的android專案有使用其他的android專案當作library&lt;/div&gt;
&lt;div&gt;
那個專案也需要有這三個檔案&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
編譯的方式是在終端機下指令&lt;/div&gt;
&lt;div&gt;
ant &amp;lt;target&amp;gt;&lt;/div&gt;
&lt;div&gt;
如果沒有給target的話 &amp;nbsp;會跑設定的預設target&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
在build.xml當中會匯入另一個custom_rules.xml，如果沒有的話就不會處理custom_rules.xml&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&amp;lt;import file=&quot;custom_rules.xml&quot; optional=&quot;true&quot; /&amp;gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
在這裡的註解中有提到你可以在custom_rules.xml使用的target&lt;/div&gt;
&lt;pre class=&quot;brush: text&quot;&gt;
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Compiled code location: ${out.classes.absolute.dir}
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
&lt;/pre&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
基本上就如同target的名稱一樣 你在哪個階段有需求就去寫那個target&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
比方說我有需求是將編出來的檔案集中到一個資料夾中並讓檔名出現編譯時間, 版本資訊&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
所以我用到-post-build 內容如下&lt;/div&gt;
&lt;pre class=&quot;brush: text&quot;&gt;
&amp;lt;target name=&quot;-post-build&quot;&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;tstamp&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;format property=&quot;package.time&quot; pattern=&quot;yyyyMMdd_HHmm&quot;/&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/tstamp&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;property name=&quot;apk.copy.name&quot; location=&quot;../android_build_apk/${ant.project.name}_${apk.tag}_${build.android.param}_${package.time}.apk&quot; /&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;echo&amp;gt;copy ${out.final.file}&amp;lt;/echo&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;echo&amp;gt;to &amp;nbsp; ${apk.copy.name}&amp;lt;/echo&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;copy file=&quot;${out.final.file}&quot; tofile=&quot;${apk.copy.name}&quot;/&amp;gt;
&amp;lt;/target&amp;gt;
&lt;/pre&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
上面這個target會將編譯產出的apk複製到指定目錄並變更檔名&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
build.android.param 這個property是設定編譯時是測試版(debug)還是正式版(release)&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;div&gt;
apk.tag是我設定在ant.properties中用來表示這是那個市場的版本&lt;/div&gt;
&lt;div&gt;
這樣產出來的檔名會是project.name_xxx_release_20130705_1453.apk的樣子&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
如果是產出signed&amp;nbsp;Application Package&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;div&gt;
在編譯的過程中會要求你輸入key的相關資訊&lt;/div&gt;
&lt;div&gt;
表示你產出多個檔的話就要輸入多次&lt;/div&gt;
&lt;div&gt;
其實可以把相關需要的參數設定到ant.properties中&lt;/div&gt;
&lt;div&gt;
就不需要輸入了&lt;/div&gt;
&lt;div&gt;
詳細的參數名稱可以參閱${sdk.dir}/tools/ant/build.xml&lt;/div&gt;
&lt;div&gt;
看看需要哪個property&lt;/div&gt;
&lt;div&gt;
我的狀況如下&lt;/div&gt;
&lt;pre class=&quot;brush: text&quot;&gt;
key.store=../libs/android/keystore/igsgames.keystore
key.alias=xxx
key.store.password=xxxxxxxx
key.alias.password=xxxxxxxx
apk.tag=gplay
&lt;/pre&gt;
&lt;div&gt;
這樣可以不用每次輸入&lt;/div&gt;
&lt;div&gt;
但相對表示你把密碼打在檔案中給人看&lt;/div&gt;
&lt;div&gt;
所以你可以在執行ant時使用-Dproperty=&quot;xxx&quot;這樣的方式輸入property&lt;/div&gt;
&lt;div&gt;
就不會有這樣的問題了&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
用ant其實還滿方便但是資料不太多&lt;/div&gt;
&lt;div&gt;
除了ant in action這本書外就是網站資料&lt;/div&gt;
&lt;div&gt;
另外在Android Studio中使用Gradie又是不同的系統&lt;/div&gt;
&lt;div&gt;
不知道下個專案還會不會有機會用ant&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/1176965411090107159/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/1176965411090107159' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/1176965411090107159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/1176965411090107159'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/08/antapk.html' title='使用ant編譯apk檔'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-2331644071691802634</id><published>2013-08-06T13:42:00.000+08:00</published><updated>2013-08-06T15:33:04.967+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="cocos2d-x"/><title type='text'>cocos2d-x i9100 音效播放當機問題</title><content type='html'>&lt;b&gt;問題描述&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;ennote&quot; style=&quot;-webkit-line-break: after-white-space; -webkit-nbsp-mode: space; word-wrap: break-word;&quot;&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
使用版本cocos2d-x 2.1.3&lt;/div&gt;
&lt;div&gt;
特定機型 i9100音效播放時當機&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
錯誤訊息&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I/DEBUG (13020): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***&lt;/div&gt;
&lt;div&gt;
I/DEBUG (13020): Build fingerprint: &#39;samsung/GT-I9100/GT-I9100:4.0.4/IMM76D/ZSLPQ:user/release-keys&#39;&lt;/div&gt;
&lt;div&gt;
I/DEBUG (13020): pid: 14187, tid: 14200 &amp;gt;&amp;gt;&amp;gt; xxx.xxxxxx.xxxx&amp;nbsp;&amp;lt;&amp;lt;&amp;lt;&lt;/div&gt;
&lt;div&gt;
I/DEBUG (13020): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000&lt;/div&gt;
&lt;div&gt;
.....&lt;/div&gt;
&lt;div&gt;
I/DEBUG (13020): #00 pc 00521476 /data/data/xxx.xxxxxx.xxxx/lib/libgame.so (_ZN12OpenSLEngine16setEffectLoopingEjb)&lt;/div&gt;
&lt;div&gt;
I/DEBUG (13020): #01 pc 00521dfa /data/data/xxx.xxxxxx.xxxx/lib/libgame.so (_ZN23SimpleAudioEngineOpenSL10playEffectEPKcb)&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
經查詢後發現cocos2d-x引擎在i9100上使用OpenSL(僅有這一隻) &amp;nbsp; 故只有i9100出現此問題&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;修改方式&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
先說這不是個好做法&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
OpenSLEngine.cpp&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
void OpenSLEngine::setEffectLooping(unsigned int effectID, bool isLooping)&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
if(sharedList().find(effectID) == sharedList().end()) return; &amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;&lt;--add add--=&quot;&quot; this=&quot;&quot;&gt;&lt;!----add--&gt;&lt;/--add&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
SLresult result;&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
vector&lt;audioplayer&gt;* vec = sharedList()[effectID];&lt;/audioplayer&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
assert(NULL != vec);&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
// get the first effect player that to be set loop config&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
vector&lt;audioplayer&gt;::iterator iter = vec-&amp;gt;begin();&lt;/audioplayer&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
AudioPlayer * player = *iter;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
主要原因應該是sharedList()[effectID];取vector&lt;audioplayer&gt;*時沒有該key的物件&lt;/audioplayer&gt;&lt;/div&gt;
&lt;div&gt;
但是vector這樣取會自行幫你產生一個物件&lt;/div&gt;
&lt;div&gt;
但該物件雖然不是NULL(故可避過assert檢查)又不是有效的物件&lt;/div&gt;
&lt;div&gt;
才會造成當機&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
引發的原因查詢後認為是如 &amp;nbsp;&lt;a href=&quot;http://www.cocos2d-x.org/boards/6/topics/26439&quot;&gt;http://www.cocos2d-x.org/boards/6/topics/26439&lt;/a&gt;&amp;nbsp;網頁上所講的一樣&lt;/div&gt;
&lt;div&gt;
因為i9100有音效數量限制所引發&lt;/div&gt;
&lt;div&gt;
之所以說這不是好做法是因為應該要減少使用音效數&lt;/div&gt;
&lt;div&gt;
或者作動態載入&lt;/div&gt;
&lt;div&gt;
緊急的狀況下只能先這樣做&lt;/div&gt;
&lt;div&gt;
但這樣做會有一些音效播不到&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/2331644071691802634/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/2331644071691802634' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/2331644071691802634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/2331644071691802634'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/08/i9100.html' title='cocos2d-x i9100 音效播放當機問題'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-2275166116101059780</id><published>2013-07-08T10:24:00.002+08:00</published><updated>2013-07-08T10:25:31.836+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>GCM在無該服務的例外狀況</title><content type='html'>&lt;div class=&quot;ennote&quot; style=&quot;-webkit-line-break: after-white-space; -webkit-nbsp-mode: space; word-wrap: break-word;&quot;&gt;
&lt;div&gt;
&lt;br clear=&quot;none&quot; /&gt;&lt;/div&gt;
&lt;div&gt;
問題：&lt;/div&gt;
&lt;div&gt;
把目前運行測試正常的檔案送給大陸廠商，卻發現無法進入遊戲&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
解答&lt;/div&gt;
&lt;div&gt;
後來弄到了出現問題的手機運行後發現下面的錯誤訊息&lt;/div&gt;
&lt;div&gt;
Caused by: java.lang.UnsupportedOperationException: Device does not have package com.google.android.gsf&lt;/div&gt;
&lt;div&gt;
E/AndroidRuntime( 787): at com.google.android.gcm.GCMRegistrar.checkDevice(GCMRegistrar.java:98)&lt;/div&gt;
&lt;div&gt;
須處理沒有該服務時例外狀況&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
重點在於大陸手機多沒有google服務&lt;br /&gt;
所以GCM部分需要處理&amp;nbsp;UnsupportedOperationException&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
所以&lt;/div&gt;
&lt;div&gt;
1. 在用google相關服務時須要考慮沒有的狀況&lt;/div&gt;
&lt;div&gt;
2. 相關服務須要找替代品(金流是很好找 &amp;nbsp;但推播就真的比較少聽過了)&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/2275166116101059780/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/2275166116101059780' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/2275166116101059780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/2275166116101059780'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/07/gcm.html' title='GCM在無該服務的例外狀況'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-6557831900721100082</id><published>2013-05-31T00:25:00.001+08:00</published><updated>2013-06-09T21:56:38.845+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>Android 問題集錦</title><content type='html'>&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;padding-bottom: 20px; padding-top: 10px; width: 100%px;&quot;&gt;    &lt;tbody&gt;
&lt;tr&gt;     &lt;td style=&quot;line-height: 1; padding-bottom: 0px; text-align: left;&quot;&gt;&lt;h3 style=&quot;color: #262626; font-size: 11px; font-weight: bold; margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;&quot;&gt;
&lt;a href=&quot;http://evernote.com/&quot; style=&quot;color: #3697b3; font-weight: bold; text-decoration: none;&quot;&gt;From Evernote:&lt;/a&gt;&lt;/h3&gt;
&lt;/td&gt;    &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;border-bottom-color: #b5b5b5; border-bottom-style: solid; border-bottom-width: 1px; font-size: 11px; line-height: 1.3; padding-bottom: 7px; padding-top: 0px; text-align: left;&quot;&gt;&lt;h1 style=&quot;color: #262626; font-size: 18px; font-weight: bold; margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 5px;&quot;&gt;
Android 問題集錦&lt;/h1&gt;
Clipped from: &lt;a href=&quot;http://developer.android.com/guide/topics/manifest/uses-feature-element.html&quot; style=&quot;color: #3697b3; font-weight: bold; text-decoration: none;&quot;&gt;http://developer.android.com/guide/topics/manifest/uses-feature-element.html&lt;/a&gt;     &lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;ennote&quot; style=&quot;-webkit-line-break: after-white-space; -webkit-nbsp-mode: space; word-wrap: break-word;&quot;&gt;
&lt;div&gt;
1.&lt;/div&gt;
&lt;div&gt;
問題：&lt;/div&gt;
&lt;div&gt;
一次更新後，所有純平版裝置都無法在Google Play中看到該App，該次更新主要提供使用簡訊小額付費機制&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
解答：&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://developer.android.com/guide/topics/manifest/uses-feature-element.html&quot;&gt;http://developer.android.com/guide/topics/manifest/uses-feature-element.html&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
因為簡訊寄送需要增加SEND_SMS這個Permission，連帶會自動將android.hardware.telephony這個feature設為需求&lt;/div&gt;
&lt;div&gt;
解法為在 androidmanifest中增加 &amp;lt;uses-featureandroid:name=&quot;android.hardware.telephony&quot;android:required=&quot;false&quot;/&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
2.&lt;/div&gt;
&lt;div&gt;
問題：&lt;/div&gt;
&lt;div&gt;
遊戲當中並沒有使用到menu鍵，但是只要手機沒有實體menu鍵的話都會出現虛擬menu鍵&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
解答：&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/7035325/how-i-hide-the-menu-button-for-one-activity&quot;&gt;http://stackoverflow.com/questions/7035325/how-i-hide-the-menu-button-for-one-activity&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
之前我沒有設定targetSdkVersion，由於targetSdkVersion預設等於minSdkVersion，而我設定的值為9，被判定為legacy，則會顯示虛擬menu鍵&lt;/div&gt;
&lt;div&gt;
targetSdkVersion設為14後則解決&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
3.&lt;/div&gt;
&lt;div&gt;
問題：&lt;/div&gt;
&lt;div&gt;
targetSdkVersion換成14後的測試期間，發現home鍵與power鍵兩種進入讓遊戲進入背景的方法的行為不同&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
解答：&lt;/div&gt;
&lt;div&gt;
請直接看&amp;nbsp;&lt;a href=&quot;http://blog.csdn.net/hunter_hb/article/details/8572095&quot;&gt;http://blog.csdn.net/hunter_hb/article/details/8572095&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
解說的十分詳細&lt;/div&gt;
&lt;div&gt;
我的設定是orientation 修改後解決&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;strike&gt;4.&lt;/strike&gt;&lt;/div&gt;
&lt;div&gt;
&lt;strike&gt;問題：&lt;/strike&gt;&lt;/div&gt;
&lt;div&gt;
&lt;strike&gt;更新&lt;span style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;Android SDK Tools&lt;/span&gt;為22版後，發現無法產生R檔，出現&quot;Error executing aapt.Please check aapt is present at /android-sdk/platform-tools/aapt&quot;&lt;/strike&gt;&lt;/div&gt;
&lt;div&gt;
&lt;strike&gt;&lt;br /&gt;&lt;/strike&gt;&lt;/div&gt;
&lt;div&gt;
&lt;strike&gt;解答：&lt;/strike&gt;&lt;/div&gt;
&lt;div&gt;
&lt;strike&gt;&lt;span style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;Android SDK Tools&amp;nbsp;&lt;/span&gt;22有問題 &amp;nbsp; aapt被移到其他路徑但是設定沒有改到&lt;/strike&gt;&lt;/div&gt;
&lt;div&gt;
&lt;strike&gt;網路找的解法&lt;/strike&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/16585099/adt-22-missing-aapt-exe-after-upgrading&quot;&gt;&lt;strike&gt;http://stackoverflow.com/questions/16585099/adt-22-missing-aapt-exe-after-upgrading&lt;/strike&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;strike&gt;我自己的做法是使用21版先不要升級&lt;/strike&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/6557831900721100082/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/6557831900721100082' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/6557831900721100082'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/6557831900721100082'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/05/android.html' title='Android 問題集錦'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-9218396034707575946</id><published>2013-05-30T01:10:00.000+08:00</published><updated>2013-05-30T01:10:38.467+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="cocos2d-x"/><category scheme="http://www.blogger.com/atom/ns#" term="cURL"/><title type='text'>專案中與cURL相關瀕繁當機處理記錄</title><content type='html'>&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;padding-bottom: 20px; padding-top: 10px; width: 100%px;&quot;&gt;    &lt;tbody&gt;
&lt;tr&gt;     &lt;td style=&quot;line-height: 1; padding-bottom: 0px; text-align: left;&quot;&gt;&lt;h3 style=&quot;color: #262626; font-size: 11px; font-weight: bold; margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;&quot;&gt;
&lt;a href=&quot;http://evernote.com/&quot; style=&quot;color: #3697b3; font-weight: bold; text-decoration: none;&quot;&gt;From Evernote:&lt;/a&gt;&lt;/h3&gt;
&lt;/td&gt;    &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;border-bottom-color: #b5b5b5; border-bottom-style: solid; border-bottom-width: 1px; font-size: 11px; line-height: 1.3; padding-bottom: 7px; padding-top: 0px; text-align: left;&quot;&gt;&lt;h1 style=&quot;color: #262626; font-size: 18px; font-weight: bold; margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 5px;&quot;&gt;
專案中與cURL相關瀕繁當機處理記錄&lt;/h1&gt;
&lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;ennote&quot; style=&quot;-webkit-line-break: after-white-space; -webkit-nbsp-mode: space; word-wrap: break-word;&quot;&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
以下是專案中遇到的一個比較特別的問題 記錄如下&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
問題：在某次上市的android版遊戲有瀕繁當機的狀況，通常是在進遊戲後不久，而這狀況在內部測試時並不常出現，且無發生在iOS版本&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
處理：&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
0.&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
本次新上市版本增加公告功能&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
由cURL進行http連線取得公告設定檔案與圖片 &amp;nbsp; 此部分使用cocos2d-x extensions的network套件&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
遊戲本身server連線程式也由cURL寫成&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
1.&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
測得兩次進遊戲後當機(花三天測試出現兩次)，看似curl程式庫引發，錯誤訊息如下：&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
Fatal signal 11 (SIGSEGV) at 0x5103a793 (code=2)&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
I/DEBUG&amp;nbsp;&amp;nbsp; (&amp;nbsp; 135): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
I/DEBUG&amp;nbsp;&amp;nbsp; (&amp;nbsp; 135): Build fingerprint: &#39;samsung/GT-I9000/GT-I9000:2.3.5/GINGERBREAD/XXJVT:user/release-keys&#39;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
I/DEBUG&amp;nbsp;&amp;nbsp; (&amp;nbsp; 135): pid: 11056, tid: 11056&amp;nbsp; &amp;gt;&amp;gt;&amp;gt; com.igs.salonbossworld &amp;lt;&amp;lt;&amp;lt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
I/DEBUG&amp;nbsp;&amp;nbsp; (&amp;nbsp; 135): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 5103a793&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
……….&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
I/DEBUG&amp;nbsp;&amp;nbsp; (&amp;nbsp; 135):&amp;nbsp; d30 0000000000000000&amp;nbsp; d31 3ff0000000000000&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
I/DEBUG&amp;nbsp;&amp;nbsp; (&amp;nbsp; 135):&amp;nbsp; scr 60000010&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
I/DEBUG&amp;nbsp;&amp;nbsp; (&amp;nbsp; 135):&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
I/DEBUG&amp;nbsp;&amp;nbsp; (&amp;nbsp; 135):&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #00&amp;nbsp; pc 005691b6&amp;nbsp; /mnt/asec/com.igs.salonbossworld-1/lib/libgame.so&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
I/DEBUG&amp;nbsp;&amp;nbsp; (&amp;nbsp; 135):&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #01&amp;nbsp; pc 0056935e&amp;nbsp; /mnt/asec/com.igs.salonbossworld-1/lib/libgame.so&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
I/DEBUG&amp;nbsp;&amp;nbsp; (&amp;nbsp; 135):&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #02&amp;nbsp; pc 0056a150&amp;nbsp; /mnt/asec/com.igs.salonbossworld-1/lib/libgame.so (&lt;span style=&quot;color: red;&quot;&gt;curl_mvsnprintf&lt;/span&gt;)&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
I/DEBUG&amp;nbsp;&amp;nbsp; (&amp;nbsp; 135):&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #03&amp;nbsp; pc 0055d014&amp;nbsp; /mnt/asec/com.igs.salonbossworld-1/lib/libgame.so (&lt;span style=&quot;color: red;&quot;&gt;curl_failf&lt;/span&gt;)&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
I/DEBUG&amp;nbsp;&amp;nbsp; (&amp;nbsp; 135):&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #04&amp;nbsp; pc 00556586&amp;nbsp; /mnt/asec/com.igs.salonbossworld-1/lib/libgame.so (&lt;span style=&quot;color: red;&quot;&gt;curl_resolv_timeout&lt;/span&gt;)&lt;/div&gt;
&lt;div style=&quot;font-family: Courier, &#39;Courier New&#39;, monospace; font-size: 11px;&quot;&gt;
I/DEBUG&amp;nbsp;&amp;nbsp; (&amp;nbsp; 135):&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #05&amp;nbsp; pc 0056308a&amp;nbsp; /mnt/asec/com.igs.salonbossworld-1/lib/libgame.so (Curl_connect)&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
2.&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
以紅色字部份作搜尋，查得幾篇技術文章有類似狀況如下&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;a href=&quot;http://sourceforge.net/p/curl/bugs/973/&quot;&gt;http://sourceforge.net/p/curl/bugs/973/&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;a href=&quot;http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=617647&quot;&gt;http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=617647&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
重點在使用cURL並在多執行緒狀況下&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
另外有篇文章說明這個狀況取決於os與thread的實作細節(回文的是官方人員)&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
http://curl.haxx.se/mail/lib-2002-12/0103.html&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
AFAIK, it isn&#39;t always specified what happens with signals in a&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
multi-threaded system, it depends on your OS and your thread implementation.&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
Which thread receives the signal etc.&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
另外官方有說明Multi-threading的相關問題&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;a href=&quot;http://curl.haxx.se/libcurl/c/libcurl-tutorial.html#Multi-threading&quot;&gt;http://curl.haxx.se/libcurl/c/libcurl-tutorial.html#Multi-threading&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
另有一篇中文說明文章 &amp;nbsp;&lt;a href=&quot;http://www.cppblog.com/tx7do/archive/2012/02/20/166048.html&quot;&gt;http://www.cppblog.com/tx7do/archive/2012/02/20/166048.html&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
3.&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
依照文章說明有2種作法&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
使用CURLOPT_NOSIGNAL，缺點是會失去DNS Lookup timeout的能力，可用增加c-ares支援解決&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
(但有文章指出某些android裝置會有問題 &amp;nbsp;&lt;a href=&quot;http://curl.haxx.se/mail/lib-2013-04/0276.html&quot;&gt;http://curl.haxx.se/mail/lib-2013-04/0276.html&lt;/a&gt;)&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
另一個方法是保持同時間只有一個curl handle，缺點需要改動程式架構&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
4.&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
基於幾點推測當機可能符合該BUG，之所以說是推測是因為無法確認玩家當機的確切原因且測試時無法完全重現&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;ul&gt;
&lt;li&gt;連server的程式都以pthread開執行緒並以curl程式庫作http連線，當遊戲剛進去有可能會更新信件與動態公告資料，此時多執行緒成立。&lt;/li&gt;
&lt;li&gt;由於取決於這個狀況取決於os與thread的實作，或許可以解釋為何iOS無該狀況發生&lt;/li&gt;
&lt;li&gt;猜測玩家之所以比較容易發生是因為玩家通常在信件上資料會比較多或者是玩家常處於不穩定網路狀況故較容易逾時。&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
5.&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
討論後將android動態公告http連線方式由cURL改為android原生方法&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
新版上市後已無該狀況&lt;/div&gt;
&lt;div style=&quot;font-family: Courier,;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/9218396034707575946/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/9218396034707575946' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/9218396034707575946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/9218396034707575946'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/05/curl.html' title='專案中與cURL相關瀕繁當機處理記錄'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-4073007186777077035</id><published>2013-05-23T01:08:00.000+08:00</published><updated>2013-05-23T01:11:42.239+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cocos2d-x"/><title type='text'>修改cocos2d-x提供build_native.sh經驗</title><content type='html'>在cocos2d-x專案中要編譯native code時會用到build_native.sh來做編譯&lt;br /&gt;
&lt;div class=&quot;ennote&quot; style=&quot;-webkit-line-break: after-white-space; -webkit-nbsp-mode: space; word-wrap: break-word;&quot;&gt;
&lt;div&gt;
這個Bash腳本會使用NDK的ndk-build&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
隨著專案越來越複雜有些需求需要特別去處理&lt;/div&gt;
&lt;div&gt;
以我自己的狀況來講&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;分為Debug與Release兩個版本&lt;/li&gt;
&lt;li&gt;分為國際版與韓國版&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
上述兩個部分都可以經由修改build_native.sh來達到&lt;/div&gt;
&lt;div&gt;
下面會分成幾個部分來說&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
先列出幾個教學網站&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://www.ibm.com/developerworks/cn/linux/l-bash-parameters.html&quot;&gt;http://www.ibm.com/developerworks/cn/linux/l-bash-parameters.html&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://linuxconfig.org/Bash_scripting_Tutorial#18-redirections&quot;&gt;http://linuxconfig.org/Bash_scripting_Tutorial#18-redirections&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://linux.vbird.org/linux_basic/0340bashshell-scripts.php&quot;&gt;http://linux.vbird.org/linux_basic/0340bashshell-scripts.php&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
我都是有需要在去查&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
基本上這個部份我是在版本2.0.3加的 &amp;nbsp;但是最新的2.1.3應該也可用&lt;/div&gt;
&lt;div&gt;
&lt;hr /&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;選項修改&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
原本build_native.sh中的選項部分的程式碼如下&lt;/div&gt;
&lt;div&gt;
其實要不是因為要改這個部份我還不知道這個腳本有選項可以用&lt;/div&gt;
&lt;div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;while getopts &quot;sh&quot; OPTION; do&lt;br /&gt;case &quot;$OPTION&quot; in&lt;br /&gt;s)&lt;br /&gt;buildexternalsfromsource=1&lt;br /&gt;;;&lt;br /&gt;h)&lt;br /&gt;usage&lt;br /&gt;exit 0&lt;br /&gt;;;&lt;br /&gt;esac&lt;br /&gt;done&lt;/span&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
上面的寫法主要是處理&quot;-s&quot;這種型態的選項&lt;/div&gt;
&lt;div&gt;
也就是說如果今天的的指令是長下面這樣&lt;/div&gt;
&lt;div&gt;
bash build_native.sh &amp;nbsp;-s &amp;nbsp;xxx&lt;/div&gt;
&lt;div&gt;
就只會處理-s的部分&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
原本是想說就再加一個選項&lt;/div&gt;
&lt;div&gt;
結果並不如我想的這樣簡單&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
基本上先看到下面跟ndk-build有關的程式碼如下&lt;/div&gt;
&lt;div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&quot;$NDK_ROOT&quot;/ndk-build -C &quot;$APP_ANDROID_ROOT&quot; &lt;span style=&quot;color: red;&quot;&gt;$*&lt;/span&gt; \&lt;br /&gt;NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source&quot;&lt;/span&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
重點在於紅字的部分&lt;/div&gt;
&lt;div&gt;
$*代表該腳本的所有參數&lt;/div&gt;
&lt;div&gt;
如果今天我用了一個ndk-build已經有的參數就會影響ndk-build的行為&lt;/div&gt;
&lt;div&gt;
如果用了一個沒有的又會說是一個invalid option&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
此時有兩個做法 &amp;nbsp;一個是把 $*拿掉&lt;/div&gt;
&lt;div&gt;
但是這樣有一個缺點&lt;/div&gt;
&lt;div&gt;
原本可以下如下指令&lt;/div&gt;
&lt;div&gt;
bash build_native.sh clean&lt;/div&gt;
&lt;div&gt;
也就是&lt;/div&gt;
&lt;div&gt;
ndk-build clean&lt;/div&gt;
&lt;div&gt;
就會變成不能用&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
另一個做法就是在選項的部分作修改&lt;/div&gt;
&lt;div&gt;
以下是我的改法&lt;/div&gt;
&lt;div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;for p in $*&lt;br /&gt;do&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &quot;$p&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case $p in&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;kr&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &quot;force build kr&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; forcebuildkr=1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Can not pass this parameter to next call bash&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;debug&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &quot;get debug&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; debugflag=1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Can not pass this parameter to next call bash&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;-s&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buildexternalsfromsource=1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; param=&quot;$param$p &quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;-h&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usage&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; param=&quot;$param$p &quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; esac&lt;br /&gt;done&lt;/span&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
這是另一種選項的做法&lt;/div&gt;
&lt;div&gt;
以上面提到的bash build_native.sh &amp;nbsp;-s &amp;nbsp;xxx&lt;/div&gt;
&lt;div&gt;
在這裡就會全都處理到&lt;/div&gt;
&lt;div&gt;
又由於我不想全部選項都傳到ndk-build&lt;/div&gt;
&lt;div&gt;
所以該傳的我就存在$param&lt;/div&gt;
&lt;div&gt;
再把$*改為$param即可&lt;/div&gt;
&lt;div&gt;
此時我已經可以透過選項來選擇我要怎樣的版本&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;hr /&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;利用Application.mk分不同的版本&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
在最早的時候&lt;/div&gt;
&lt;div&gt;
我在分debug與release版的時候是直接去android.mk中修改CPPFLAG&lt;/div&gt;
&lt;div&gt;
後來覺得實在是太麻煩要改來改去&lt;/div&gt;
&lt;div&gt;
就採取我現在使用的方法&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
ndk-build有一個選項&lt;/div&gt;
&lt;div&gt;
ndk-build NDK_APPLICATION_MK=&lt;file&gt;&lt;/file&gt;&lt;/div&gt;
&lt;div&gt;
可以讓你自己指定要使用的Application.mk&lt;/div&gt;
&lt;div&gt;
所以我將不同狀況需要的CPPFLAG設定寫到不同的Application.mk檔中&lt;/div&gt;
&lt;div&gt;
再依照選項不同設定不同的數值去決定到底要用哪一個&lt;/div&gt;
&lt;div&gt;
大概如下&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;if [[ &quot;$debugflag&quot; ]]; then&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &quot;debug on!!&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [[ &quot;$forcebuildkr&quot; ]]; then&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &quot;force build kr!!&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usedebugappmk=&quot;${APP_ANDROID_ROOT}/jni/Application_debug_kr.mk&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &quot;build global!!&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usedebugappmk=&quot;${APP_ANDROID_ROOT}/jni/Application_debug.mk&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;
else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &quot;debug off!!&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [[ &quot;$forcebuildkr&quot; ]]; then&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &quot;force build kr!!&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usedebugappmk=&quot;${APP_ANDROID_ROOT}/jni/Application_kr.mk&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &quot;build global!!&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usedebugappmk=&quot;${APP_ANDROID_ROOT}/jni/Application.mk&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;
fi&lt;br /&gt;&quot;$NDK_ROOT&quot;/ndk-build NDK_APPLICATION_MK=&quot;$usedebugappmk&quot; -C &quot;$APP_ANDROID_ROOT&quot; $param \&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt&quot;&lt;/span&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;hr /&gt;
&lt;b&gt;控制資源&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
一般cocos2d-x專案的資源檔都放在Resource資料夾下&lt;/div&gt;
&lt;div&gt;
後來我遇到了某種情況是某些檔案只在android狀況下改變&lt;/div&gt;
&lt;div&gt;
所以我另外開個一個資料夾Resource_android&lt;/div&gt;
&lt;div&gt;
在原本的# copy resources腳本下&lt;/div&gt;
&lt;div&gt;
添加了一段處理android特有資源的程式&lt;/div&gt;
&lt;div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;# copy ver android&lt;br /&gt;for file in &quot;$APP_ROOT&quot;/Resource_android/*&lt;br /&gt;do&lt;br /&gt;if [ -d &quot;$file&quot; ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp -rf &quot;$file&quot; &quot;$APP_ANDROID_ROOT&quot;/assets&lt;br /&gt;fi&lt;br /&gt;if [ -f &quot;$file&quot; ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp &quot;$file&quot; &quot;$APP_ANDROID_ROOT&quot;/assets&lt;br /&gt;fi&lt;br /&gt;done&lt;/span&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
另外也可以將腳本寫在別的.sh中在去呼叫&lt;/div&gt;
&lt;div&gt;
如下&lt;/div&gt;
&lt;div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;if [[ &quot;$debugflag&quot; -ne 1 ]]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &quot;delete .lua .bat .exe&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ -e &quot;del_lua.sh&quot; ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ./del_lua.sh&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;fi&lt;/span&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
專案在做release版時會將lua檔全部刪除&lt;/div&gt;
&lt;div&gt;
這部分是寫在另一個.sh中&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/4073007186777077035/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/4073007186777077035' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/4073007186777077035'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/4073007186777077035'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/05/cocos2d-xbuildnativesh.html' title='修改cocos2d-x提供build_native.sh經驗'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-2652997578870355457</id><published>2013-05-22T00:26:00.003+08:00</published><updated>2013-05-22T00:34:11.277+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JNI"/><title type='text'>JNI中是否需要自行呼叫DeleteLocalRef</title><content type='html'>&lt;br /&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
這是一個被問到我一時之間答不出來的問題，後來去找了一下&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
&lt;span style=&quot;text-align: -webkit-auto;&quot;&gt;JNI電子書籍&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://192.9.162.55/docs/books/jni/&quot; style=&quot;text-align: -webkit-auto;&quot;&gt;http://192.9.162.55/docs/books/jni/&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.soi.city.ac.uk/~kloukin/IN2P3/material/jni.pdf&quot;&gt;http://www.soi.city.ac.uk/~kloukin/IN2P3/material/jni.pdf&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;&quot;&gt;
下面是相關說明 &amp;nbsp;引自&amp;nbsp;&lt;a href=&quot;http://192.9.162.55/docs/books/jni/html/refs.html&quot;&gt;http://192.9.162.55/docs/books/jni/html/refs.html&lt;/a&gt;&lt;/div&gt;
&lt;blockquote&gt;
A local reference is valid only within the dynamic context of the native method that creates it, and only within that one invocation of the native method. All local references created during the execution of a native method will be freed once the native method returns.&amp;nbsp;&lt;/blockquote&gt;
&lt;blockquote&gt;
There are two ways to invalidate a local reference. As explained before, the virtual machine automatically frees all local references created during the execution of a native method after the native method returns. In addition, programmers may explicitly manage the lifetime of local references using JNI functions such as&amp;nbsp;DeleteLocalRef.&amp;nbsp;&lt;/blockquote&gt;
&lt;blockquote&gt;
Why do you want to delete local references explicitly if the virtual machine automatically frees them after native methods return? A local reference keeps the referenced object from being garbage collected until the local reference is invalidated. The&amp;nbsp;DeleteLocalRef&amp;nbsp;call in&amp;nbsp;MyNewString, for example, allows the intermediate array object,&amp;nbsp;elemArr, to be garbage collected immediately. Otherwise the virtual machine will only be able to free the&amp;nbsp;elemArr&amp;nbsp;object after the native method that calls&amp;nbsp;MyNewString&amp;nbsp;(such as&amp;nbsp;C.f&amp;nbsp;above) returns.&lt;/blockquote&gt;
基本上就是說&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Local Reference只在其創建方法的dynamic context內有效。&lt;/li&gt;
&lt;li&gt;兩個狀況下Local Reference會失效：使用DeleteLocalRef，其創建方法返回時。&lt;/li&gt;
&lt;li&gt;既然返回時會失效為啥要呼叫DeleteLocalRef，在於呼叫後就立刻允許VM回收而非等到方法返回之後。&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
個人感覺，這跟java中將用完物件的ref設為null的感覺很像。&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/2652997578870355457/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/2652997578870355457' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/2652997578870355457'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/2652997578870355457'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/05/jnideletelocalref.html' title='JNI中是否需要自行呼叫DeleteLocalRef'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-7582249683280452016</id><published>2013-04-19T19:18:00.001+08:00</published><updated>2013-04-19T19:18:17.198+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>問題記錄：Android設定寄送夾帶附件的E-mail時附件無法使用</title><content type='html'>&lt;div class=&quot;ennote&quot; style=&quot;-webkit-line-break: after-white-space; -webkit-nbsp-mode: space; word-wrap: break-word;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;color: #3665ee;&quot;&gt;問題起因：&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
基本上使用常見的方法如下&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Intent i = new Intent(Intent.ACTION_SEND);&lt;/div&gt;
&lt;div&gt;
i.setType(&quot;image/jpeg&quot;);&lt;/div&gt;
&lt;div&gt;
i.putExtra(Intent.EXTRA_EMAIL&amp;nbsp; , new String[]{sendTarget});&lt;/div&gt;
&lt;div&gt;
i.putExtra(Intent.EXTRA_SUBJECT, sendSubject);&lt;/div&gt;
&lt;div&gt;
i.putExtra(Intent.EXTRA_TEXT&amp;nbsp;&amp;nbsp; , sendText);&lt;/div&gt;
&lt;div&gt;
i.putExtra(Intent.EXTRA_STREAM, Uri.parse(&quot;file://&quot;+ filePath));&lt;/div&gt;
&lt;div&gt;
try {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;curActivity.startActivity(Intent.createChooser(i, &quot;Please select Email client&quot;));&lt;/div&gt;
&lt;div&gt;
} catch (android.content.ActivityNotFoundException ex) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Toast.makeText(curActivity, &quot;There are no email clients installed.&quot;, Toast.LENGTH_SHORT).show();&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
問題出於我給的是&lt;a href=&quot;http://developer.android.com/guide/topics/data/data-storage.html#filesInternal&quot;&gt;Internal Storage&lt;/a&gt;的路徑，所以基本上當其它的應用程式要取用檔案時有有存取權限問題&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #3665ee;&quot;&gt;解決方式:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
copy一份到&lt;a href=&quot;http://developer.android.com/guide/topics/data/data-storage.html#filesExternal&quot;&gt;External Storage&lt;/a&gt;再用copy檔的路徑即可&lt;/div&gt;
&lt;div&gt;
聽起來很簡單 &amp;nbsp;但我還是被卡了&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
File externalPicPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);&lt;/div&gt;
&lt;div&gt;
File dstFile = new File(externalPicPath, &quot;picture.png&quot;);&lt;/div&gt;
&lt;div&gt;
try{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; FileInputStream in = new FileInputStream(filePath);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; FileOutputStream out = new FileOutputStream(dstFile);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; byte[] buf = new byte[1024];&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; int len;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; while ((len = in.read(buf)) &amp;gt; 0) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out.write(buf, 0, len);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; in.close();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; out.close();&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
catch(IOException e)&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Toast.makeText(curActivity, &quot;I/O Error.&quot;, Toast.LENGTH_SHORT).show();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;return;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/7582249683280452016/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/7582249683280452016' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/7582249683280452016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/7582249683280452016'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/04/androide-mail.html' title='問題記錄：Android設定寄送夾帶附件的E-mail時附件無法使用'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14721237.post-4028001020144213008</id><published>2013-04-19T18:56:00.000+08:00</published><updated>2013-04-19T18:56:02.734+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Unity"/><title type='text'>Unity練習：設定Menu選項</title><content type='html'>&lt;br /&gt;&lt;div class=&quot;ennote&quot; style=&quot;-webkit-line-break: after-white-space; -webkit-nbsp-mode: space; word-wrap: break-word;&quot;&gt;
&lt;div&gt;
在其他人的plugin中常會看到一些設定Menu選項的方法&lt;/div&gt;
&lt;div&gt;
整理如下&lt;/div&gt;
&lt;div&gt;
&lt;br clear=&quot;none&quot; /&gt;&lt;/div&gt;
&lt;div&gt;
[AddComponentMenu(&quot;Test/MenuTest&quot;)]&lt;/div&gt;
&lt;div&gt;
public class MenuTest : MonoBehaviour {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; ......&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
增加在Component，主要用來為game object 增加 component用&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP-1rrPjOjs68qRz03uJcpJ58YB73qpmbJnzllHTqUA41025fe5issx7sQbf8GMlMXVcDHHZaEyxTdvvhV-nmYCWyDfPGNEbh9K_xoGS6W34VkJ6XvCXhM_K0HPtgTOEc2df6-/s1600/26ca1ea8b965a2fc7478fceb288407b8-778913.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP-1rrPjOjs68qRz03uJcpJ58YB73qpmbJnzllHTqUA41025fe5issx7sQbf8GMlMXVcDHHZaEyxTdvvhV-nmYCWyDfPGNEbh9K_xoGS6W34VkJ6XvCXhM_K0HPtgTOEc2df6-/s320/26ca1ea8b965a2fc7478fceb288407b8-778913.png&quot; id=&quot;BLOGGER_PHOTO_ID_5868509651026995250&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;hr /&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
[MenuItem (&quot;MyMenu/func_a&quot;)]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //must static&lt;br /&gt;
static void func_a()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ....&lt;br /&gt;
}&lt;/div&gt;
&lt;div&gt;
在Menu bar中增加選項&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpVwL8lZ3xQ8cpWrw6c34RdxuF3_gRR4lWBPCo1Qnm0XVy2mmV-D_OyoZ41XSizDDMT5OELyP8CfwcRMpLnKYs9CjFY3yHkKUkP8zxxO1vlcpp5SMslq3t0GL45GqwVWKBwfPk/s1600/4dba2e6af79817ebd35a3868a1c22d03-781603.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpVwL8lZ3xQ8cpWrw6c34RdxuF3_gRR4lWBPCo1Qnm0XVy2mmV-D_OyoZ41XSizDDMT5OELyP8CfwcRMpLnKYs9CjFY3yHkKUkP8zxxO1vlcpp5SMslq3t0GL45GqwVWKBwfPk/s320/4dba2e6af79817ebd35a3868a1c22d03-781603.png&quot; id=&quot;BLOGGER_PHOTO_ID_5868509661637952130&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
也可以加到GameObject Menu下&lt;/div&gt;
&lt;div&gt;
[MenuItem(&quot;GameObject/Selection/Force Delete&quot;)] (NGUI)&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcfcBgX7aLkwV9qRnaoX6NeVTueUvvPHUhgO7ypCG5_gVAm6W_okLE9ccIhAt0w6D8EvZFRT04jHTG4c-gMDhtkW3RdvI-SWHe2eZk-TJZ24qdWTHAS3DaswPveA-Uj4IJNemD/s1600/857243090c8d9cce0e3f91a5be061db4-782578.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcfcBgX7aLkwV9qRnaoX6NeVTueUvvPHUhgO7ypCG5_gVAm6W_okLE9ccIhAt0w6D8EvZFRT04jHTG4c-gMDhtkW3RdvI-SWHe2eZk-TJZ24qdWTHAS3DaswPveA-Uj4IJNemD/s320/857243090c8d9cce0e3f91a5be061db4-782578.png&quot; id=&quot;BLOGGER_PHOTO_ID_5868509665474328546&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;hr /&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
[ContextMenu (&quot;func_b&quot;)] // must non static&lt;br /&gt;
void func_b()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ....&lt;br /&gt;
}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
[MenuItem (&quot;CONTEXT/MenuTest/func_c&quot;)]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //must static&lt;br /&gt;
static void func_c()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ....&lt;br /&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
這兩個做法出現的地方一樣都是&lt;span style=&quot;background-color: white; color: #444444; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 17px;&quot;&gt;inspector context menu&lt;/span&gt;&amp;nbsp;，但有點不同，ContextMenu只能只定非static的方法上，而[MenuItem (&quot;CONTEXT/....&quot;)] 只能用在static方法上&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7JGP2rWRKDzDTW-lKbeVL68VNoZdw1bK0f915hUhjH_DfogEayRX71s7Wb951f7cG8f3zq3zcs8gDX7L4Ky1xjTMPPym1ixQOonpwZ-GBW88mtmKsbm69vQJYRjDGpOpG84NY/s1600/ce6472e55c4f66d7018600cb89d58bcd-783833.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7JGP2rWRKDzDTW-lKbeVL68VNoZdw1bK0f915hUhjH_DfogEayRX71s7Wb951f7cG8f3zq3zcs8gDX7L4Ky1xjTMPPym1ixQOonpwZ-GBW88mtmKsbm69vQJYRjDGpOpG84NY/s320/ce6472e55c4f66d7018600cb89d58bcd-783833.png&quot; id=&quot;BLOGGER_PHOTO_ID_5868509669128375698&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
有看到再加&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
ref:&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://docs.unity3d.com/Documentation/ScriptReference/AddComponentMenu.html&quot;&gt;http://docs.unity3d.com/Documentation/ScriptReference/AddComponentMenu.html&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://docs.unity3d.com/Documentation/ScriptReference/MenuItem.html&quot;&gt;http://docs.unity3d.com/Documentation/ScriptReference/MenuItem.html&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://docs.unity3d.com/Documentation/ScriptReference/ContextMenu.html&quot;&gt;http://docs.unity3d.com/Documentation/ScriptReference/ContextMenu.html&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hsienwei.blogspot.com/feeds/4028001020144213008/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/14721237/4028001020144213008' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/4028001020144213008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14721237/posts/default/4028001020144213008'/><link rel='alternate' type='text/html' href='http://hsienwei.blogspot.com/2013/04/unitymenu_19.html' title='Unity練習：設定Menu選項'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06179118896302507235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP-1rrPjOjs68qRz03uJcpJ58YB73qpmbJnzllHTqUA41025fe5issx7sQbf8GMlMXVcDHHZaEyxTdvvhV-nmYCWyDfPGNEbh9K_xoGS6W34VkJ6XvCXhM_K0HPtgTOEc2df6-/s72-c/26ca1ea8b965a2fc7478fceb288407b8-778913.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>