Skip to content

Instantly share code, notes, and snippets.

@AndreiRudenko
Last active August 29, 2015 14:27
Show Gist options
  • Save AndreiRudenko/a552494073c9a9353c2b to your computer and use it in GitHub Desktop.
Save AndreiRudenko/a552494073c9a9353c2b to your computer and use it in GitHub Desktop.
A custom ParcelProgress for Luxe that shows a splashscreen
package;
import luxe.Sprite;
import luxe.Color;
import luxe.Parcel;
import luxe.ParcelProgress;
import luxe.options.ParcelProgressOptions;
class ParcelSplash extends ParcelProgress
{
var sprite:Sprite;
var displayed:Bool = false;
var time_fadein:Float = 2;
var time_fadeout:Float = 1;
var time_wait:Float = 1; // Time to wait before fadein start
var time_display:Float = 1; // How long the sprite will be displayed
public function new(_options:ParcelProgressOptions)
{
options = _options;
options.no_visuals = true;
super(options);
sprite = new Sprite({
name:'logo_luxe',
texture:Luxe.resources.texture('assets/sprites/luxe.png'),
pos:Luxe.screen.mid,
color:new Color(1,1,1,0)
});
Luxe.timer.schedule(time_wait, fadein);
}
override function onprogress(_state:ParcelChange)
{
}
override function oncomplete(_parcel:Parcel)
{
if (displayed)
{
fadeout();
}
else
{
Luxe.timer.schedule(Luxe.timer.timers[1].fire_at + time_display, fadeout);
}
}
function fadein()
{
sprite.color.tween(time_fadein, {a:1});
Luxe.timer.schedule(time_fadein + time_display, function(){displayed = true;});
}
function fadeout()
{
sprite.color.tween(time_fadeout, {a:0});
Luxe.timer.schedule(time_fadeout, docomplete);
}
function docomplete()
{
options.oncomplete(options.parcel);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment