發表文章

目前顯示的是 12月, 2013的文章

[Android]讓物件持續旋轉不停頓

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator">     <rotate     android:duration="360"     android:fromDegrees="0"     android:pivotX="50%"     android:pivotY="50%"     android:repeatCount="infinite"     android:toDegrees="360"/> </set> 加入android:interpolator="@android:anim/linear_interpolator"就不會有停頓。 參考資料: http://www.techques.com/question/1-8648662/How-to-remove-lag-when-Rotate-Animation-repeats-on-Android

[Android]Facebook 登入

首先下載Facebook的SDK:https://developers.facebook.com/docs/android/ 匯入到新專案之後 1.打開res/values/string.xml加入<string name="app_id">AppID</string> 2.打開AndroidManifest.xml 加入<uses-permission android:name="android.permission.INTERNET"/> 3.並新增一個Activity  <activity android:name="com.facebook.LoginActivity" />         <meta-data android:name="com.facebook.sdk.ApplicationId"                   android:value="@string/app_id"/> 4.在onActivityResult上加入如下   protected void onActivityResult(int requestCode, int resultCode, Intent data) {                super.onActivityResult(requestCode, resultCode, data); if(resultCode == RESULT_OK) { switch (requestCode) { case 64206: Session.getActiveSession().onActivityResult(MainActivity.this, requestCode, resultCode, data);

[Unity]Excel存TXT給Unity讀取

public TextAsset binAsset;//TXT檔 private string [] lineArray; //讀取列 private string [][] valueArray; //儲存所有資料 void Start() {       lineArray = binAsset.text.Split ("\r"[0]); // 以\r做為一個段落       valueArray = new string [lineArray.Length][];         for(int i =0;i < lineArray.Length; i++)         {             valueArray[i] = lineArray[i].Split ("\t"[0]); // 以\t為一個資訊         } } 透過Excel填入的資訊再儲存成TXT檔,再把TXT檔丟到Unity給TextAsset,再由以上的程式去讀取。

HSV轉Color

public static Color ColorFromHSV(float h, float s, float v, float a = 0) {         // no saturation, we can return the value across the board (grayscale)         if (s == 0)             return new Color(v, v, v, a);         // which chunk of the rainbow are we in?         float sector = h / 60;         // split across the decimal (ie 3.87 into 3 and 0.87)         int i = (int)sector;         float f = sector - i;         float p = v * (1 - s);         float q = v * (1 - s * f);         float t = v * (1 - s * (1 - f));         // build our rgb color         Color color = new Color(0, 0, 0, a);         switch(i)         {             case 0:                 color.r = v;                 color.g = t;                 color.b = p;                 break;             case 1:                 color.r = q;                 color.g = v;                 color.b = p;                 break;             case 2:                 colo