﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AnimatedGif : MonoBehaviour {

	public float imagesParSecondes;

	public Sprite[] sprites;
	

	private float period;
	private int index;

	// Use this for initialization
	void Start () {
		period = 1 / imagesParSecondes;
		Debug.Log(period);

		InvokeRepeating("changeImage", 0, period);
	}
	
	// Update is called once per frame
	void Update () {
		
	}


	void changeImage() {
		index = (index + 1) % sprites.Length;
		Debug.Log(index);

		GetComponent<SpriteRenderer>().sprite = sprites[index];
	}
}
