-
Notifications
You must be signed in to change notification settings - Fork 1
Window
GhostglowDev edited this page Mar 21, 2024
·
2 revisions
local wnd = require "ghostutil.window"
This was not fun to make
For eases, check out FlxEase
-
defaultDimensions
:Array<Int> =
{
width = 1280,
height = 720
}
-
desktopDimensions
:Array[Int] - Stores your desktop's width and height
-
tag
: For pausing/resuming, cancelling and foronTweenCompleted()
-
value
: The window's target x position -
duration
: The duration it takes to complete (in seconds) -
ease
: FlxEase
wnd.windowTweenX("windowx", 780, 3, "expoOut")
-
tag
: For pausing/resuming, cancelling and foronTweenCompleted()
-
value
: The window's target y position -
duration
: The duration it takes to complete (in seconds) -
ease
: FlxEase
wnd.windowTweenY("windowy", 525, 3, "expoOut")
-
tag
: For pausing/resuming, cancelling and foronTweenCompleted()
-
value
: The window's target y position. If the values are both the same, useFloat
instead. -
duration
: The duration it takes to complete (in seconds) -
ease
: FlxEase
-- {x: 100, y: 600}
wnd.windowTweenPosition("hello", {100, 600}, 3, "expoOut")
-- {x, y: 500}
wnd.windowTweenPosition("world", 500, 2, "expoOut")
Centers the window with tweens
-
tag
: For pausing/resuming, cancelling and foronTweenCompleted()
-
axis
:"xy"
,"x"
or"y"
. -
duration
: The duration it takes to complete (in seconds) -
ease
: FlxEase
-- Centers the window on both axis
wnd.tweenToCenter("centerwindow", "xy", 3, "expoOut")
-- Centers the window only on the x axis
wnd.tweenToCenter("centerwindow", "x", 3, "expoOut")
-
tag
: For pausing/resuming, cancelling and foronTweenCompleted()
-
dimensions
: The width and height in table. If both values are the same, useFloat
instead. -
duration
: The duration it takes to complete (in seconds) -
ease
: FlxEase
-- Sets the window dimension to a 720x720px square
wnd.tweenResizeTo("windowsize", 720, 3, "expoOut")
-- Sets the window dimension to the default
wnd.tweenResizeTo("windowsize", {
wnd.defaultDimensions.width,
wnd.defaultDimensions.height
}, 3, "expoOut")
-
tag
: Window tween tag
function onCreatePost()
wnd.windowTweenX("windowtest", wnd.desktopDimensions.width / 1.2, 8, "smootherStepInOut")
end
function onSongStart()
wnd.pauseTween("windowtest")
end
function onStepHit()
if curStep == 32 then
wnd.resumeTween("windowtest")
end
end
-- Plays a tween onCreatePost and pausing it onSongStart.
-- Resumes on step 32
wnd.close()
-
position
: The new position in a table. If both values are the same, useFloat
instead.
-- {x: 0, y: 100}
wnd.setPosition({0, 100})
-- {x, y: 10}
wnd.setPosition(10)
-
axis
:"xy"
,"x"
or"y"
.
wnd.screenCenter("xy")
Self-explanatory. If both values are the same, use Float
instead.
-- {width, height = 720}
wnd.resizeTo(720)
-
title
: Alert window's Title -
message
: Alert window's message -
Use
\n
to create a new line
wnd.alert("Thank you", "Thanks for using GhostUtil! :D")
-
title
: Application title (When empty, it will set the title back toFriday Night Funkin': Psych Engine"
)
wnd.changeTitle("Friday Night Funkin': Testing Ghost's Utilities")
Should be self-explanatory
-
windowName
: Used for accessing the new window inrunHaxeCode
. -
attributes
: The attributes for the new window. (All values are optional)
{
position:Array<Float>,
dimensions:Array<Float>,
title:String,
resizable:Bool,
minimized:Bool,
maximized:Bool,
fullscreen:Bool
borderless:Bool,
alwaysOnTop:Bool
}
-
closeOnDestroy
: Should the window close when you exit the song, die, etc.
function onCreatePost()
wnd.createWindow("bob", {
{100, 100}, -- x, y
{720, 720}, -- width, height
"hi im bob" -- title
-- unnecessary values are not included
});
end
-
variable
: The name of the window property -
value
: New value
- borderless (Bool)
- height (Float)
- width (Float)
- x (Float)
- y (Float)
- fullscreen (Bool)
- title (String)
- resizable / canResize (Bool)
wnd.setProperty("borderless", true)
-
variable
: The name of the window property to fetch
- borderless (Bool)
- height (Float)
- width (Float)
- x (Float)
- y (Float)
- fullscreen (Bool)
- title (String)
- resizable / canResize (Bool)
wnd.getProperty("x")
Reading this wiki is recommended before using GhostUtil