Author Topic: Fading background sprite  (Read 14982 times)

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Fading background sprite
« on: July 12, 2012, 08:03:16 AM »
Hi,

I'm building a menu for my IOS app and it's the first time im using nGUI, but i'm having some trouble finding out how to fade a sprite. I'm guessing using the alpha values would help. I tried using TweenColor but i can't use the alpha value there. Anyone know how to fade sprites?

Thx for the help!
« Last Edit: July 12, 2012, 08:08:14 AM by Tripwire »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fading background sprite
« Reply #1 on: July 12, 2012, 08:41:13 AM »
Why can't you? A color has 4 components -- red, green, blue, and alpha.

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: Fading background sprite
« Reply #2 on: July 12, 2012, 08:49:38 AM »
Can you give me a code example in JS onn how to use the TweenColor function with alpha values? I think i'm using it wrong then.

Also i build my first test on Ipod Touch, but all my textures are white / gone. I only see my red sphere floating in a white space. I have 2 panels in my scene:
1: A panel which holds the background and header sprite for my app
2: A panel which holds buttons, an overlay texture, and a menu header sprite

Thx!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fading background sprite
« Reply #3 on: July 12, 2012, 09:01:48 AM »
Make sure the shader you're using on whatever you're tweening actually supports alpha blending.

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: Fading background sprite
« Reply #4 on: July 12, 2012, 09:09:13 AM »
Make sure the shader you're using on whatever you're tweening actually supports alpha blending.

I'm not using TweenColor at the moment, but the build still doesn't show the textures on Ipod Touch. Are there some special settings i need to use when creating a sprite atlas?
Settings of all my textures:
Texture Type: Texture
Alpha from Grayscale turned off
Wrap Mode: Clamp
Filter Mode: Point
Max Size: 1024
Format: True color

Or is it something else that goed wrong? In the game view everything works perfectly.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fading background sprite
« Reply #5 on: July 12, 2012, 09:14:21 AM »
There is nothing special. If you're using a clipped panel, you need shaders enabled (GLES 1.1 emulation = no shader support).

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: Fading background sprite
« Reply #6 on: July 12, 2012, 09:40:48 AM »
There is nothing special. If you're using a clipped panel, you need shaders enabled (GLES 1.1 emulation = no shader support).

I have no emulation selected, my sprite atlas is 2048 X 1024. Still everything is white / gone when building to Ipod Touch running IOS 4.2 (2nd gen). Is my ipod to old to use nGUI or something?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fading background sprite
« Reply #7 on: July 12, 2012, 09:43:26 AM »
2nd gen iPod touch is limited to 1024x1024 texture size. You've exceeded that. It also doesn't have shaders, so clipping won't work.

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: Fading background sprite
« Reply #8 on: July 12, 2012, 10:04:15 AM »
Thx got it working now, can you still show me an example code of TweenColor  using the alpha value?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fading background sprite
« Reply #9 on: July 12, 2012, 10:20:49 AM »
TweenColor.Begin(yourGameObject, duration, new Color(1f, 1f, 1f, 0f));

See the "0f"? That's alpha.