Skip to content

Instantly share code, notes, and snippets.

@ChunChunMorning ChunChunMorning/Main.cpp
Last active Dec 11, 2015

Embed
What would you like to do?
Siv3Dで簡単なアニメーションを作る
# include <Siv3D.hpp>
class Anime
{
public:
Anime(const Texture& texture, int size, int frame) :
m_texture(texture),
m_size(size),
m_frame(frame),
m_index(0),
m_count(0) {}
void update()
{
++m_count;
if (m_count > m_frame)
{
m_count = 0;
++m_index;
if (m_index >= m_size)
{
m_index = 0;
}
}
}
void draw(const Vec2& pos) const
{
m_texture.uv(static_cast<double>(m_index) / m_size, 0.0, 1.0 / m_size, 1.0).draw(pos);
}
private:
Texture m_texture;
int m_size;
int m_frame;
int m_index;
int m_count;
};
void Main()
{
Texture texture(L"AsachunAnime.png");
Anime anime(texture, 4, 10);
while (System::Update())
{
anime.update();
anime.draw(Mouse::Pos());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.