纳金网

标题: 【转】拾取物品后弹出名称(图片)渐渐消失 [打印本页]

作者: 晃晃    时间: 2011-7-28 11:20
标题: 【转】拾取物品后弹出名称(图片)渐渐消失
var myRect : Rect;

var myRectBG : Rect;

var myText : Texture;

var myTextBG : Texture;

var remainingTime : float;

var startTime = 60.0;

//(assuming you want to start with 60 seconds) //the width (in pixels) that represents one second

var WIDTH_PER_SECOND = 2;

function Start()

{

myRect = Rect(Screen.width / 2 - 256, Screen.height / 2-16 ,512,32);

myRectBG =Rect(Screen.width / 2 - 256, Screen.height / 2-16 ,512,32);

//begin with 'startTime' seconds on the clock remainingTime = startTime;

}

function Update()

{

remainingTime -= Time.deltaTime*5;

myRect.width = remainingTime * WIDTH_PER_SECOND;

if (myRect.width < 0)

{

myRect.width = 0;

}

}

function OnGUI()

{

//GUI.BeginGroup(Rect (Screen.width / 2 - 250, Screen.height / 2 - 50, 500, 100)); GUI.DrawTexture(myRect, myText);

GUI.DrawTexture(myRectBG , myTextBG);

}

function OnControllerColliderHit(hit:ControllerColliderHit)

{

if(hit.gameObject.tag == "gem")

{

Destroy(hit.gameObject); //add 5 seconds to the timer remainingTime += 50;

}

}
作者: 彬彬    时间: 2011-8-2 21:18
写的好
作者: tc    时间: 2012-2-7 23:29
好,真棒!!

作者: 奇    时间: 2012-4-6 23:18
心中有爱,爱咋咋地

作者: C.R.CAN    时间: 2012-6-2 23:20
我看看就走,你们聊!

作者: 晃晃    时间: 2012-7-8 23:27
呵呵,真得不错哦!!

作者: 奇    时间: 2012-8-6 23:51
先顶上去,偶要高亮加精鸟!

作者: 晃晃    时间: 2012-10-15 23:29
跑着去顶朋友滴铁

作者: C.R.CAN    时间: 2012-10-22 23:30
很经典,很实用,学习了!

作者: 菜刀吻电线    时间: 2012-11-28 23:22
无聊时可以刷屏幕 灌水 也可以试试 帖子的标题究竟可以写多长

作者: 奇    时间: 2013-1-31 23:28
无聊时可以刷屏幕 灌水 也可以试试 帖子的标题究竟可以写多长





欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5