Skip to content

cgh20xx/Sprite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sprite.js

Demo

Download

Sprite.js Sprite.min.js

Example1

var sp = new Sprite({
    el: '#test',
    fps: 18,
    // duration: 3000, // set duration will ignore fps
    width: 320,
    height: 320,
    imgBaseUrl: 'images/',
    imgName: 'demo-',
    imgType: '.png',
    imgStartIndex: 0,
    imgEndIndex: 27,
    repeat: -1,
    autoPlay: false
}).init();

sp
.on('load', function(source) {
    sp.play();
})
.on('play', function() {
    ...
})
.on('stop', function() {
    ...
})
.on('resume', function() {
    ...
});

btnPlay.addEventListener('click', function(e) {
    sp.play();
});

btnStop.addEventListener('click', function(e) {
    sp.stop();
});

btnResume.addEventListener('click', function(e) {
    sp.resume();
});

Example2

You can use .mount() append to HTMLElemnt.

var sp = new Sprite({
    fps: 18,
    width: 320,
    height: 320,
    imgBaseUrl: 'images/',
    imgName: 'demo-',
    imgType: '.png',
    imgStartIndex: 0,
    imgEndIndex: 27,
    repeat: -1,
    autoPlay: false
}).init();

sp
.on('load', function(source) {
    var test = document.getElementById('test');
    this.mount(test);
})
.on('mounted', function() {
    this.play();
});

About

序列圖動畫工具,可設定動畫 FPS 及重播次數並提供 play、stop、resume 等方法。

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published