Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
A better way to fade a scene in... — Gideros Forum

A better way to fade a scene in...

Tom2012Tom2012 Guru
edited October 2012 in General questions
I've been using scene manager to fade scenes in and out.

The problem I found is that if you have different layers of images, you'll get an odd effect where you can see the edges of the graphics.

One thing that seems to work well is creating a black shape and then fading the black shape out (at the start of the scene) then in (at the end of the scene).

Here's the code:

To fade in a scene:
-- Add black overlay
 
local blackOverlay = Shape.new()
blackOverlay:setFillStyle(Shape.SOLID, 0x000000)      
blackOverlay:beginPath()
blackOverlay:lineTo(0, 480)
blackOverlay:lineTo(320, 480)
blackOverlay:lineTo(320, 0)
blackOverlay:lineTo(0, 0)
blackOverlay:endPath()
self:addChild(blackOverlay)
 
-- Now fade it out
 
local tween = GTween.new(blackOverlay, .4, {alpha=0})
To fade out the scene:
local tween = GTween.new(blackOverlay, .6, {alpha=1})
Tested on device and it looks sexy! B-)

Likes: duke2017, Bill5567

+1 -1 (+2 / -0 )Share on Facebook

Comments

Sign In or Register to comment.