Ligth not working on native targets

111 views
Skip to first unread message

Tembac

unread,
Dec 15, 2014, 6:55:12 PM12/15/14
to haxef...@googlegroups.com
Hello Community,


It works on flash but not on native targets: Windows, Android and neko tested.


If we make it work I can update the tutorial and post it to the haxeflixel docs. 

SruloArt

unread,
Dec 16, 2014, 3:35:54 AM12/16/14
to haxef...@googlegroups.com
I'm working on the dev branch so I can't directly test this (too lazy :|), but maybe the reason it doesn't work on native is because you need to import openfl.display.BlendMode; not the flash one (which is only relevant to flash with the new OpenFL version, AFAIK)...

Also * ligHT not ligTH :P

Also, I think there's a better lighting method: http://deepnight.net/bresenham-magic-raycasting-line-of-sight-pathfinding/ (search for "lighting").

Side note, Maybe we can have helpers algorithms, like a FlxBresenham for example...

Tembac

unread,
Dec 16, 2014, 4:31:58 PM12/16/14
to haxef...@googlegroups.com
Ups, I always make the same mistake with the "th" and "ht"

Thanks but I don't need something so advanced. If I would need to do something like that I think I would use nape: http://napephys.com/samples.html#swf-SpatialQueries
There is another similar guide here: http://ncase.me/sight-and-light/

I made the change of blendmode but It still doesn't work on native targets :( The dev branch is too diferent for this example?

Tiago Ling

unread,
Dec 23, 2014, 9:27:54 AM12/23/14
to haxef...@googlegroups.com
Afaik, blend modes work in Flash target only - this is a limitation of OpenFL / Lime.

SruloArt

unread,
Dec 23, 2014, 10:11:48 AM12/23/14
to haxef...@googlegroups.com
Addition, Multiply and Screen are supported on all targets (native uses software though). Theoretically, I read, the new Lime/OpenFL libs support even more blend modes for native (using Hardware), but they are not yet implemented.

Tiago Ling

unread,
Dec 23, 2014, 12:25:09 PM12/23/14
to haxef...@googlegroups.com
Yeah, i stand corrected, OpenFl does have them on native. Hopefully we'll have gpu blend modes soon.

Tembac

unread,
Dec 23, 2014, 3:28:47 PM12/23/14
to haxef...@googlegroups.com
Still doesn't work for me. What am I doing wrong?

solewalker

unread,
Dec 24, 2014, 1:56:11 AM12/24/14
to
Tembac you are calling super.draw() first in draw() function of Playstate. Call this after processing light and updating graphics like this:

    override public function draw():Void
   
{
       
        ligth
.setPosition(FlxG.mouse.x - ligth.width * .5, FlxG.mouse.y - ligth.height * .5);
       
       
var gfx:Graphics = FlxSpriteUtil.flashGfxSprite.graphics;
        gfx
.clear();

        darknessCanvas
.pixels.fillRect(new Rectangle(0, 0, FlxG.width, FlxG.height), 0xff000000);
       
FlxSpriteUtil.updateSpriteGraphic(darknessCanvas);
       
super.draw();

   
}

 By the way, this process is very slow in mobile target, as stamping function is not hardware accelerated, for a single light you wont notice, but for many lights its gonna be slow.

Tembac

unread,
Dec 24, 2014, 3:13:19 PM12/24/14
to haxef...@googlegroups.com
Thanks! It works now!

Do you now any alternative for mobiles?

(Happy Holidays! )


On Wednesday, December 24, 2014 3:56:11 AM UTC-3, solewalker wrote:
Tembac you are calling super.draw() first in draw() function of Playstate. Call this after processing light and updating graphics like this:

    override public function draw():Void
   
{
       
        ligth
.setPosition(FlxG.mouse.x - ligth.width * .5, FlxG.mouse.y - ligth.height * .5);
       
       
var gfx:Graphics = FlxSpriteUtil.flashGfxSprite.graphics;
        gfx
.clear();

        darknessCanvas
.pixels.fillRect(new Rectangle(0, 0, FlxG.width, FlxG.height), 0xff000000);
       
FlxSpriteUtil.updateSpriteGraphic(darknessCanvas);
       
super.draw();

   
}

 By the way, this process is very slow in mobile target, as stamping function is not hardware accelerated, for a single light you wont notice, but for many lights its gonna be slow.

On Wednesday, December 24, 2014 2:28:47 AM UTC+6, Tembac wrote:
Reply all
Reply to author
Forward
0 new messages