Author Topic: Adjusting Color Tint of UISprite using javascript  (Read 3146 times)

gateian

  • Guest
Adjusting Color Tint of UISprite using javascript
« on: November 21, 2012, 07:01:36 PM »
Hi Guys,

Loving NGUI so far. Really takes the chore out of GUI work. I've managed to get my gui working good, but now I want to interact with it and control it using javascript, which I have coded my entire game in.

First thing I want to do is get a sprite flashing gradually by adjusting the color tint alpha value. I don't know how to access the color tint value of a sprite from my javascript that is assigned to the same object. Could anybody help?

I'm hoping I don't have to code the whole game in C#!

RandomGuy

  • Guest
Re: Adjusting Color Tint of UISprite using javascript
« Reply #1 on: November 21, 2012, 07:18:57 PM »
You don't have to code your whole game in C# , but your going to need to make a handler that talks to a C# script to get it to do this . Their are ways to get NGUI to work with JS, but their not worth the trouble in most cases

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Adjusting Color Tint of UISprite using javascript
« Reply #2 on: November 22, 2012, 12:35:32 AM »
NGUI with javascript is the same as NGUI with C#. You just need to follow instructions in the FAQ: http://www.tasharen.com/forum/index.php?topic=6.msg13#msg13

gateian

  • Guest
Re: Adjusting Color Tint of UISprite using javascript
« Reply #3 on: November 22, 2012, 10:21:22 AM »
Thanks for the link. That should get me started.

gateian

  • Guest
Re: Adjusting Color Tint of UISprite using javascript
« Reply #4 on: November 22, 2012, 01:21:13 PM »
Ok forgive me guys, but i'm not the strongest coder in the world. I looked at the FAQ and tried to work out how to do this, but alas i still don't quite understand.

I've attached a javascript to one of my UILabel objects and at the start of the script I have put the line of code...

  1. UILabel lbl = GetComponent<UILabel>();


as described in the FAQ. Is this c#? Is there a javascript equivalent? as I am getting an error with this line. I was assuming this would allow me to reference the UILabel in the script.

gateian

  • Guest
Re: Adjusting Color Tint of UISprite using javascript
« Reply #5 on: November 22, 2012, 05:16:45 PM »
aha!

Never mind. I figured it out. I was being a dummy and put the c# scripts in the wrong folder and so the above line was not recognising what a UILabel was because it hadn't been compiled yet.  8)