mirror of
https://forge.univ-lyon1.fr/tplifap4/dungeonanddeamon.git
synced 2024-02-27 13:31:50 +01:00
ajout animation mobs+ input player + animation
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
#include "MobsCorpACorpIA.h"
|
||||
#include <ConfigFile.hpp>
|
||||
#include <SpriteFrames.hpp>
|
||||
#include <Input.hpp>
|
||||
#include <ResourceLoader.hpp>
|
||||
#include <Texture.hpp>
|
||||
@ -8,7 +9,7 @@
|
||||
|
||||
MobsCorpACorpIA::MobsCorpACorpIA()
|
||||
{
|
||||
sprite_MobsCorpACorp_ptr = Sprite::_new();
|
||||
sprite_MobsCorpACorp_ptr = AnimatedSprite::_new();
|
||||
collision_MobsCorpACorp_ptr = CollisionShape2D::_new();
|
||||
texture_MobsCorpACorp_ptr.instance();
|
||||
texture_MobsCorpACorp_ptr->_new();
|
||||
@ -37,6 +38,7 @@ void MobsCorpACorpIA::_physics_process(float dt)
|
||||
|
||||
void MobsCorpACorpIA::_process(float delta)
|
||||
{
|
||||
animation();
|
||||
}
|
||||
|
||||
void MobsCorpACorpIA::_init()
|
||||
@ -63,20 +65,25 @@ void MobsCorpACorpIA::setupMobsCorpACorp()
|
||||
|
||||
|
||||
//Setup du shape
|
||||
Godot::print("SetUp de Shape Mobs");
|
||||
shape_MobsCorpACorp_ptr.ptr()->_new();
|
||||
|
||||
|
||||
//Chargement de la texture
|
||||
Godot::print("SetUp de Texture Mobs");
|
||||
texture_MobsCorpACorp_ptr = ResourceLoader::get_singleton()->load("res://Character/Fire Elemental Sprite Sheet/fireelemental00.png");
|
||||
|
||||
//setup du sprite
|
||||
Godot::print("SetUp de Sprite Mobs");
|
||||
sprite_MobsCorpACorp_ptr->set_texture(texture_MobsCorpACorp_ptr);
|
||||
//Godot::print("SetUp de Sprite");
|
||||
Ref<SpriteFrames> spriteFrames = ResourceLoader::get_singleton()->load("res://Character/Fire Elemental Sprite Sheet/fireelement.tres");
|
||||
sprite_MobsCorpACorp_ptr->set_sprite_frames(spriteFrames);
|
||||
|
||||
PoolStringArray AnimNames = spriteFrames->get_animation_names();
|
||||
PoolStringArray::Read r = AnimNames.read();
|
||||
Godot::print("Animations Names");
|
||||
for (int i = 0; i < AnimNames.size(); ++i)
|
||||
{
|
||||
Godot::print(r[i]);
|
||||
}
|
||||
|
||||
//setup du collision Shape
|
||||
Godot::print("SetUp de CollisionShape Mobs");
|
||||
collision_MobsCorpACorp_ptr->set_shape(shape_MobsCorpACorp_ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -133,6 +140,32 @@ void MobsCorpACorpIA::mouvement(float dt)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MobsCorpACorpIA::animation()
|
||||
{
|
||||
|
||||
if (m.velocity.x > 0.0f)
|
||||
{
|
||||
sprite_MobsCorpACorp_ptr->play("walk");
|
||||
sprite_MobsCorpACorp_ptr->set_flip_h(false);
|
||||
}
|
||||
else if (m.velocity.x < 0.0f)
|
||||
{
|
||||
sprite_MobsCorpACorp_ptr->play("walk");
|
||||
sprite_MobsCorpACorp_ptr->set_flip_h(true);
|
||||
}
|
||||
else if (pv <=0 )
|
||||
{
|
||||
sprite_MobsCorpACorp_ptr->play("dead");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite_MobsCorpACorp_ptr->play("idle");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void MobsCorpACorpIA::droit()
|
||||
|
Reference in New Issue
Block a user