implement defineLightSource
This commit is contained in:
@@ -30,6 +30,7 @@ import openfl.display.BitmapData;
|
|||||||
import openfl.display.BitmapDataChannel;
|
import openfl.display.BitmapDataChannel;
|
||||||
import openfl.geom.Rectangle;
|
import openfl.geom.Rectangle;
|
||||||
import openfl.geom.Point;
|
import openfl.geom.Point;
|
||||||
|
import flixel.input.mouse.FlxMouseEventManager;
|
||||||
|
|
||||||
@:build(kiss.Kiss.build())
|
@:build(kiss.Kiss.build())
|
||||||
class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, String, FlxSprite, FlxSound, FlxCamera, FlxLightSource> {
|
class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, String, FlxSprite, FlxSound, FlxCamera, FlxLightSource> {
|
||||||
@@ -40,6 +41,6 @@ class FlxDirector implements Director<FlxSprite, ActorFlxSprite, FlxSound, Strin
|
|||||||
data.copyChannel(mask.pixels, new Rectangle(0, 0, sprite.width, sprite.height), new Point(), BitmapDataChannel.RED, BitmapDataChannel.ALPHA);
|
data.copyChannel(mask.pixels, new Rectangle(0, 0, sprite.width, sprite.height), new Point(), BitmapDataChannel.RED, BitmapDataChannel.ALPHA);
|
||||||
output.pixels = data;
|
output.pixels = data;
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,9 +91,57 @@
|
|||||||
(prop &mut :FlxSprite darkness null)
|
(prop &mut :FlxSprite darkness null)
|
||||||
(prop &mut :FlxColor darkColor FlxColor.BLACK)
|
(prop &mut :FlxColor darkColor FlxColor.BLACK)
|
||||||
|
|
||||||
|
(var &mut :FlxMouseEventManager mm null)
|
||||||
|
|
||||||
|
(method :Void chooseString [:String prompt :Array<String> choices :String->Void submit]
|
||||||
|
(kiss_flixel.SimpleWindow.promptForChoice
|
||||||
|
prompt
|
||||||
|
choices
|
||||||
|
submit
|
||||||
|
FlxColor.BLACK
|
||||||
|
FlxColor.WHITE
|
||||||
|
0.8
|
||||||
|
0.8
|
||||||
|
true
|
||||||
|
"escape"
|
||||||
|
"left"
|
||||||
|
"right"))
|
||||||
|
|
||||||
|
(method :Void defineFlxPoint [:FlxPoint->Void submit]
|
||||||
|
(unless mm
|
||||||
|
(set mm (new FlxMouseEventManager))
|
||||||
|
(FlxG.state.add mm))
|
||||||
|
(let [screen (new FlxSprite)]
|
||||||
|
(screen.makeGraphic FlxG.width FlxG.height (FlxColor.fromRGBFloat 0 1 0 0.2))
|
||||||
|
(set screen.cameras [flxMovie.uiCamera])
|
||||||
|
(mm.add screen
|
||||||
|
->screen {
|
||||||
|
(mm.remove screen)
|
||||||
|
(FlxG.state.remove screen)
|
||||||
|
(submit (FlxG.mouse.getScreenPosition flxMovie.uiCamera))
|
||||||
|
})
|
||||||
|
(FlxG.state.add screen)))
|
||||||
|
|
||||||
(method :Void defineLightSource [:FlxLightSource->Void submit]
|
(method :Void defineLightSource [:FlxLightSource->Void submit]
|
||||||
// TODO
|
(let [points []]
|
||||||
(submit (new FlxLightSource [(new FlxPoint 830 225) (new FlxPoint 316 719) (new FlxPoint 1120 719)] FlxColor.TRANSPARENT)))
|
(withFunctions
|
||||||
|
[
|
||||||
|
(getNextPoint []
|
||||||
|
(defineFlxPoint
|
||||||
|
->point
|
||||||
|
{
|
||||||
|
(points.push point)
|
||||||
|
(getNextPoint)
|
||||||
|
}))
|
||||||
|
]
|
||||||
|
(getNextPoint)
|
||||||
|
(sh.registerItem
|
||||||
|
"{enter} submit light source"
|
||||||
|
(onceLambda [cc]
|
||||||
|
(when points
|
||||||
|
// TODO allow color choice
|
||||||
|
(submit (new FlxLightSource points FlxColor.TRANSPARENT)))
|
||||||
|
(cc))))))
|
||||||
|
|
||||||
(method :Void showLighting [:SceneTime sceneTime :Array<FlxLightSource> lightSources :FlxCamera camera]
|
(method :Void showLighting [:SceneTime sceneTime :Array<FlxLightSource> lightSources :FlxCamera camera]
|
||||||
(set lightSprite (new FlxSprite))
|
(set lightSprite (new FlxSprite))
|
||||||
|
|||||||
@@ -196,6 +196,8 @@
|
|||||||
})
|
})
|
||||||
(shortcutHandler.registerItem "{escape} Pause the movie"
|
(shortcutHandler.registerItem "{escape} Pause the movie"
|
||||||
->cc (director.showPauseMenu cc))
|
->cc (director.showPauseMenu cc))
|
||||||
|
|
||||||
|
// TODO (#when debug)
|
||||||
(shortcutHandler.registerItem "[d]efine [l]ight source"
|
(shortcutHandler.registerItem "[d]efine [l]ight source"
|
||||||
->cc
|
->cc
|
||||||
(director.defineLightSource
|
(director.defineLightSource
|
||||||
|
|||||||
Reference in New Issue
Block a user