Make the positioning of the hand sprite dynamic bsed on size and also done once during init instead of every render.
This commit is contained in:
parent
af69bd2286
commit
af4ee30ade
1 changed files with 5 additions and 1 deletions
|
|
@ -20,6 +20,11 @@ namespace gui {
|
||||||
|
|
||||||
$hand = textures::get_sprite(config["player"]["hands"]);
|
$hand = textures::get_sprite(config["player"]["hands"]);
|
||||||
$hand_anim = animation::load("assets/animation.json", config["player"]["hands"]);
|
$hand_anim = animation::load("assets/animation.json", config["player"]["hands"]);
|
||||||
|
|
||||||
|
int width = $hand_anim.sheet.frame_width;
|
||||||
|
int height = $hand_anim.sheet.frame_height;
|
||||||
|
$hand.sprite->setPosition({float(RAY_VIEW_X + (RAY_VIEW_WIDTH - width) / 2), float(RAY_VIEW_HEIGHT - height)});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainUI::dirty() {
|
void MainUI::dirty() {
|
||||||
|
|
@ -152,7 +157,6 @@ namespace gui {
|
||||||
if($hand_anim.playing) {
|
if($hand_anim.playing) {
|
||||||
$hand_anim.update();
|
$hand_anim.update();
|
||||||
$hand_anim.apply(*$hand.sprite);
|
$hand_anim.apply(*$hand.sprite);
|
||||||
$hand.sprite->setPosition({RAY_VIEW_X, RAY_VIEW_Y});
|
|
||||||
$window.draw(*$hand.sprite);
|
$window.draw(*$hand.sprite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue