Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GameDevWeek
Sommersemester 2015
Cpp
Deth Buff Arr
Commits
27099204
Commit
27099204
authored
Sep 27, 2015
by
Michael Ochmann
Browse files
added manual override for frameanimation initialized with -1
parent
9fad3629
Changes
4
Hide whitespace changes
Inline
Side-by-side
assets/ui/HUD.json
View file @
27099204
...
...
@@ -36,9 +36,10 @@
"type"
:
"animation"
,
"id"
:
"level"
,
"frames"
:
[
"ui/level/Lvlanzeige_blank_1.png"
"ui/level/Lvlanzeige_blank_1.png"
,
"ui/level/Lvlanzeige_blank_2.png"
],
"frametime"
:
0
,
"frametime"
:
-1
,
"x"
:
80
,
"y"
:
-5
,
"height"
:
"auto"
,
...
...
@@ -53,7 +54,41 @@
"y"
:
2
,
"height"
:
8
,
"width"
:
15
,
"childs"
:
[]
"childs"
:
[
{
"type"
:
"animation"
,
"id"
:
"coin"
,
"frames"
:
[
"ui/coin/Frame_01.png"
,
"ui/coin/Frame_03.png"
,
"ui/coin/Frame_05.png"
,
"ui/coin/Frame_07.png"
,
"ui/coin/Frame_09.png"
,
"ui/coin/Frame_11.png"
,
"ui/coin/Frame_13.png"
,
"ui/coin/Frame_15.png"
,
"ui/coin/Frame_17.png"
,
"ui/coin/Frame_19.png"
,
"ui/coin/Frame_21.png"
,
"ui/coin/Frame_23.png"
,
"ui/coin/Frame_25.png"
,
"ui/coin/Frame_27.png"
,
"ui/coin/Frame_29.png"
,
"ui/coin/Frame_31.png"
,
"ui/coin/Frame_33.png"
,
"ui/coin/Frame_35.png"
,
"ui/coin/Frame_37.png"
,
"ui/coin/Frame_39.png"
],
"frametime"
:
0.1
,
"x"
:
0
,
"y"
:
0
,
"height"
:
100
,
"width"
:
"auto"
,
"childs"
:
[]
}
]
}
]
}
...
...
include/ui/frameanimation_widget.hpp
View file @
27099204
...
...
@@ -10,15 +10,22 @@ namespace gdw {
class
frameanimation_widget
:
public
ui_widget
{
private:
std
::
vector
<
std
::
unique_ptr
<
nanovg_texture
>>
textures
;
float
deltaSum
;
float
frameTime
;
int
activeTexture
;
public:
frameanimation_widget
(
float
x
,
float
y
,
float
width
,
float
height
,
float
frameTime
,
std
::
vector
<
std
::
unique_ptr
<
nanovg_texture
>>&
textures
);
virtual
void
render
(
NVGcontext
*
context
,
float
delta_time
)
override
;
};
void
next
()
{
this
->
activeTexture
=
this
->
activeTexture
>=
this
->
textures
.
size
()
-
1
?
0
:
this
->
activeTexture
+
1
;
}
void
previous
()
{
this
->
activeTexture
=
this
->
activeTexture
<=
0
?
(
int
)
this
->
textures
.
size
()
-
1
:
this
->
activeTexture
-
1
;
}
};
}
}
#endif //GDW_SS15_CPP_FRAMEANIMATION_WIDGET_HPP
src/game_state_machine/play_state.cpp
View file @
27099204
...
...
@@ -35,6 +35,7 @@
#include <ui/box_widget.hpp>
#include <ui/UIManager.hpp>
#include <ui/texture_widget.hpp>
#include <ui/frameanimation_widget.hpp>
#include <ui/text_widget.hpp>
namespace
gdw
{
...
...
src/ui/frameanimation_widget.cpp
View file @
27099204
#include <ui/frameanimation_widget.hpp>
#include <ui/nanovg_texture.hpp>
#include <util/logger.hpp>
namespace
gdw
{
frameanimation_widget
::
frameanimation_widget
(
float
x
,
float
y
,
float
width
,
float
height
,
float
frameTime
,
std
::
vector
<
std
::
unique_ptr
<
nanovg_texture
>>&
textures
)
:
ui_widget
(
x
,
y
,
width
,
height
),
textures
(
std
::
move
(
textures
)),
activeTexture
(
0
),
frameTime
(
frameTime
)
{
frameTime
(
frameTime
),
deltaSum
(
0.0
f
){
}
void
frameanimation_widget
::
render
(
NVGcontext
*
context
,
float
delta_time
)
{
NVGpaint
imgPaint
;
int
imgw
,
imgh
;
this
->
deltaSum
+=
delta_time
;
if
(
this
->
frameTime
!=
-
1
)
{
if
(
this
->
deltaSum
>=
frameTime
)
{
this
->
deltaSum
=
0.0
f
;
this
->
activeTexture
=
this
->
activeTexture
>=
this
->
textures
.
size
()
-
1
?
0
:
this
->
activeTexture
+
1
;
}
}
nvgImageSize
(
context
,
this
->
textures
[
this
->
activeTexture
]
->
nanovg_image_handele
,
&
imgw
,
&
imgh
);
float
aspect
=
(
float
)
imgw
/
(
float
)
imgh
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment