image-script updates part 1
This commit is contained in:
@@ -167,16 +167,27 @@ Specify Sprite properties, like position, size, etc.
|
||||
- [constructor]ImageParams(float posX, float posY, float width, opt float height)
|
||||
- GetPos() : Vector result
|
||||
- GetSize() : Vector result
|
||||
- GetPivot() : Vector result
|
||||
- GetColor() : Vector result
|
||||
- GetOpacity() : float result
|
||||
- GetFade() : float result
|
||||
- GetRotation() : float result
|
||||
- GetMipLevel() : float result
|
||||
- GetDrawRect() : Vector result
|
||||
- IsDrawRectEnabled() : bool result
|
||||
- IsMirrorEnabled() : bool result
|
||||
- SetPos(Vector pos)
|
||||
- SetSize(Vector size)
|
||||
- SetPivot(Vector value)
|
||||
- SetColor(Vector size)
|
||||
- SetOpacity(float opacity)
|
||||
- SetFade(float fade)
|
||||
- SetRotation(float rotation)
|
||||
- SetMipLevel(float mipLevel)
|
||||
- EnableDrawRect(Vector value)
|
||||
- DisableDrawRect()
|
||||
- EnableMirror()
|
||||
- DisableMirror()
|
||||
|
||||
#### SpriteAnim
|
||||
Animate Sprites easily with this helper.
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ void EditorLoadingScreen::Load()
|
||||
WIFALIGN_CENTER, WIFALIGN_CENTER));
|
||||
addFont(&font);
|
||||
|
||||
sprite = wiSprite("../logo/logo_small.png");
|
||||
sprite = wiSprite("../images/logo_small.png");
|
||||
sprite.anim.opa = 1;
|
||||
sprite.anim.repeatable = true;
|
||||
sprite.params.pos = XMFLOAT3(wiRenderer::GetDevice()->GetScreenWidth()*0.5f, wiRenderer::GetDevice()->GetScreenHeight()*0.5f - font.textHeight(), 0);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<img align="left" src="logo/logo_small.png" width="128px"/>
|
||||
<img align="left" src="images/logo_small.png" width="128px"/>
|
||||
|
||||
# Wicked Engine
|
||||
|
||||
|
||||
+5
-5
@@ -360,7 +360,7 @@ void TestsRenderer::RunSpriteTest()
|
||||
|
||||
// Simple sprite, no animation:
|
||||
{
|
||||
static wiSprite sprite("../logo/logo_small.png");
|
||||
static wiSprite sprite("../images/logo_small.png");
|
||||
sprite.params = params;
|
||||
addSprite(&sprite);
|
||||
|
||||
@@ -376,7 +376,7 @@ void TestsRenderer::RunSpriteTest()
|
||||
|
||||
// Simple sprite, fade animation:
|
||||
{
|
||||
static wiSprite sprite("../logo/logo_small.png");
|
||||
static wiSprite sprite("../images/logo_small.png");
|
||||
sprite.params = params;
|
||||
sprite.anim = wiSprite::Anim();
|
||||
sprite.anim.fad = 1.2f; // (you can also do opacity animation with sprite.anim.opa)
|
||||
@@ -395,7 +395,7 @@ void TestsRenderer::RunSpriteTest()
|
||||
|
||||
// Simple sprite, wobble animation:
|
||||
{
|
||||
static wiSprite sprite("../logo/logo_small.png");
|
||||
static wiSprite sprite("../images/logo_small.png");
|
||||
sprite.params = params;
|
||||
sprite.anim = wiSprite::Anim();
|
||||
sprite.anim.wobbleAnim.amount = XMFLOAT2(1.2f, 0.8f);
|
||||
@@ -413,7 +413,7 @@ void TestsRenderer::RunSpriteTest()
|
||||
|
||||
// Simple sprite, rotate animation:
|
||||
{
|
||||
static wiSprite sprite("../logo/logo_small.png");
|
||||
static wiSprite sprite("../images/logo_small.png");
|
||||
sprite.params = params;
|
||||
sprite.anim = wiSprite::Anim();
|
||||
sprite.anim.rot = 2.8f;
|
||||
@@ -432,7 +432,7 @@ void TestsRenderer::RunSpriteTest()
|
||||
|
||||
// Simple sprite, movingtex:
|
||||
{
|
||||
static wiSprite sprite("images/movingtex.png", "../logo/logo_small.png"); // first param is the texture we will display (and also scroll here). Second param is a mask texture
|
||||
static wiSprite sprite("images/movingtex.png", "../images/logo_small.png"); // first param is the texture we will display (and also scroll here). Second param is a mask texture
|
||||
// Don't overwrite all params for this, because we want to keep the mask...
|
||||
sprite.params.pos = params.pos;
|
||||
sprite.params.siz = params.siz;
|
||||
|
||||
@@ -18,6 +18,8 @@ VertextoPixel main(uint vI : SV_VERTEXID)
|
||||
|
||||
Out.tex = inTex * xTexMulAdd.xy + xTexMulAdd.zw;
|
||||
|
||||
Out.tex.x = xMirror == 1 ? (1 - Out.tex.x) : Out.tex.x;
|
||||
|
||||
Out.pos2D = Out.pos;
|
||||
|
||||
return Out;
|
||||
|
||||
@@ -6,17 +6,28 @@ const char wiImageParams_BindLua::className[] = "ImageParams";
|
||||
Luna<wiImageParams_BindLua>::FunctionType wiImageParams_BindLua::methods[] = {
|
||||
lunamethod(wiImageParams_BindLua, GetPos),
|
||||
lunamethod(wiImageParams_BindLua, GetSize),
|
||||
lunamethod(wiImageParams_BindLua, GetPivot),
|
||||
lunamethod(wiImageParams_BindLua, GetColor),
|
||||
lunamethod(wiImageParams_BindLua, GetOpacity),
|
||||
lunamethod(wiImageParams_BindLua, GetFade),
|
||||
lunamethod(wiImageParams_BindLua, GetRotation),
|
||||
lunamethod(wiImageParams_BindLua, GetMipLevel),
|
||||
lunamethod(wiImageParams_BindLua, GetDrawRect),
|
||||
lunamethod(wiImageParams_BindLua, IsDrawRectEnabled),
|
||||
lunamethod(wiImageParams_BindLua, IsMirrorEnabled),
|
||||
|
||||
lunamethod(wiImageParams_BindLua, SetPos),
|
||||
lunamethod(wiImageParams_BindLua, SetSize),
|
||||
lunamethod(wiImageParams_BindLua, SetPivot),
|
||||
lunamethod(wiImageParams_BindLua, SetColor),
|
||||
lunamethod(wiImageParams_BindLua, SetOpacity),
|
||||
lunamethod(wiImageParams_BindLua, SetFade),
|
||||
lunamethod(wiImageParams_BindLua, SetRotation),
|
||||
lunamethod(wiImageParams_BindLua, SetMipLevel),
|
||||
lunamethod(wiImageParams_BindLua, EnableDrawRect),
|
||||
lunamethod(wiImageParams_BindLua, DisableDrawRect),
|
||||
lunamethod(wiImageParams_BindLua, EnableMirror),
|
||||
lunamethod(wiImageParams_BindLua, DisableMirror),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<wiImageParams_BindLua>::PropertyType wiImageParams_BindLua::properties[] = {
|
||||
@@ -38,6 +49,16 @@ int wiImageParams_BindLua::GetSize(lua_State* L)
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat2(¶ms.siz)));
|
||||
return 1;
|
||||
}
|
||||
int wiImageParams_BindLua::GetPivot(lua_State* L)
|
||||
{
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat2(¶ms.pivot)));
|
||||
return 1;
|
||||
}
|
||||
int wiImageParams_BindLua::GetColor(lua_State* L)
|
||||
{
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat4(¶ms.col)));
|
||||
return 1;
|
||||
}
|
||||
int wiImageParams_BindLua::GetOpacity(lua_State* L)
|
||||
{
|
||||
wiLua::SSetFloat(L, params.opacity);
|
||||
@@ -58,6 +79,21 @@ int wiImageParams_BindLua::GetMipLevel(lua_State* L)
|
||||
wiLua::SSetFloat(L, params.mipLevel);
|
||||
return 1;
|
||||
}
|
||||
int wiImageParams_BindLua::GetDrawRect(lua_State* L)
|
||||
{
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat4(¶ms.drawRect)));
|
||||
return 1;
|
||||
}
|
||||
int wiImageParams_BindLua::IsDrawRectEnabled(lua_State* L)
|
||||
{
|
||||
wiLua::SSetBool(L, params.isDrawRectEnabled());
|
||||
return 1;
|
||||
}
|
||||
int wiImageParams_BindLua::IsMirrorEnabled(lua_State* L)
|
||||
{
|
||||
wiLua::SSetBool(L, params.isMirrorEnabled());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int wiImageParams_BindLua::SetPos(lua_State* L)
|
||||
{
|
||||
@@ -93,6 +129,40 @@ int wiImageParams_BindLua::SetSize(lua_State* L)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int wiImageParams_BindLua::SetPivot(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Vector_BindLua* vector = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
if (vector != nullptr)
|
||||
{
|
||||
XMStoreFloat2(¶ms.pivot, vector->vector);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "SetPivot(Vector value) not enough arguments!");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int wiImageParams_BindLua::SetColor(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Vector_BindLua* vector = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
if (vector != nullptr)
|
||||
{
|
||||
XMStoreFloat4(¶ms.col, vector->vector);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "SetColor(Vector value) not enough arguments!");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int wiImageParams_BindLua::SetOpacity(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
@@ -145,6 +215,40 @@ int wiImageParams_BindLua::SetMipLevel(lua_State* L)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int wiImageParams_BindLua::EnableDrawRect(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Vector_BindLua* vector = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
if (vector != nullptr)
|
||||
{
|
||||
XMFLOAT4 drawrect;
|
||||
XMStoreFloat4(&drawrect, vector->vector);
|
||||
params.enableDrawRect(drawrect);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "EnableDrawRect(Vector value) not enough arguments!");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int wiImageParams_BindLua::DisableDrawRect(lua_State* L)
|
||||
{
|
||||
params.disableDrawRect();
|
||||
return 0;
|
||||
}
|
||||
int wiImageParams_BindLua::EnableMirror(lua_State* L)
|
||||
{
|
||||
params.enableMirror();
|
||||
return 0;
|
||||
}
|
||||
int wiImageParams_BindLua::DisableMirror(lua_State* L)
|
||||
{
|
||||
params.disableMirror();
|
||||
return 0;
|
||||
}
|
||||
|
||||
wiImageParams_BindLua::wiImageParams_BindLua(lua_State *L)
|
||||
{
|
||||
|
||||
@@ -18,17 +18,28 @@ public:
|
||||
|
||||
int GetPos(lua_State* L);
|
||||
int GetSize(lua_State* L);
|
||||
int GetPivot(lua_State* L);
|
||||
int GetColor(lua_State* L);
|
||||
int GetOpacity(lua_State* L);
|
||||
int GetFade(lua_State* L);
|
||||
int GetRotation(lua_State* L);
|
||||
int GetMipLevel(lua_State* L);
|
||||
int GetDrawRect(lua_State* L);
|
||||
int IsDrawRectEnabled(lua_State* L);
|
||||
int IsMirrorEnabled(lua_State* L);
|
||||
|
||||
int SetPos(lua_State* L);
|
||||
int SetSize(lua_State* L);
|
||||
int SetPivot(lua_State* L);
|
||||
int SetColor(lua_State* L);
|
||||
int SetOpacity(lua_State* L);
|
||||
int SetFade(lua_State* L);
|
||||
int SetRotation(lua_State* L);
|
||||
int SetMipLevel(lua_State* L);
|
||||
int EnableDrawRect(lua_State* L);
|
||||
int DisableDrawRect(lua_State* L);
|
||||
int EnableMirror(lua_State* L);
|
||||
int DisableMirror(lua_State* L);
|
||||
|
||||
static void Bind();
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wiVersion
|
||||
// minor features, major updates
|
||||
const int minor = 26;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 18;
|
||||
const int revision = 19;
|
||||
|
||||
|
||||
long GetVersion()
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
@@ -32,6 +32,7 @@ local function Character(face, shirt_color)
|
||||
effect_hit = INVALID_ENTITY,
|
||||
effect_guard = INVALID_ENTITY,
|
||||
effect_spark = INVALID_ENTITY,
|
||||
sprite_hpbar = Sprite(),
|
||||
face = 1, -- face direction (X)
|
||||
request_face = 1, -- the suggested facing of this player, it might not be the actual facing if the player haven't been able to turn yet (for example an other action hasn't finished yet)
|
||||
position = Vector(), -- the absolute position of this player in the world, a 2D Vector
|
||||
@@ -1068,6 +1069,12 @@ local function Character(face, shirt_color)
|
||||
scene.Merge(effect_scene)
|
||||
|
||||
|
||||
|
||||
-- HP bar, etc. sprites:
|
||||
self.sprite_hpbar = Sprite("../images/hp_bar.png")
|
||||
main.GetActivePath().AddSprite(self.sprite_hpbar)
|
||||
|
||||
|
||||
self:StartState(self.state)
|
||||
|
||||
end,
|
||||
@@ -1172,6 +1179,24 @@ local function Character(face, shirt_color)
|
||||
self.velocity.SetY(0) -- don't fall below ground
|
||||
self.velocity = vector.Multiply(self.velocity, 0.86) -- ground drag
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- update sprites:
|
||||
local scaling = GetScreenWidth() / 3840.0
|
||||
local fx = self.sprite_hpbar.GetParams()
|
||||
fx.SetPos(Vector(GetScreenWidth() / 2 + 140 * scaling * self.face, GetScreenHeight() / 16))
|
||||
fx.SetSize(vector.Multiply(Vector(1430, 180), scaling))
|
||||
fx.EnableDrawRect(Vector(0, 0, 1430, 180))
|
||||
fx.SetColor(Vector(1,0,0,1))
|
||||
if(self.face<0) then
|
||||
fx.EnableMirror()
|
||||
fx.SetPivot(Vector(1,0))
|
||||
else
|
||||
fx.DisableMirror()
|
||||
fx.SetPivot(Vector(0,0))
|
||||
end
|
||||
self.sprite_hpbar.SetParams(fx)
|
||||
|
||||
end,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user