/
spineplayer.vue
98 lines (98 loc) · 3.35 KB
/
spineplayer.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<template>
<div class="wrap">
<div>
<div class="dev" ref="3-7">3.7</div>
<div class="dev" ref="3-8">3.8</div>
</div>
<div v-if="body1Loaded && body2Loaded">
<button class="button" @click="changeStatus">{{playStatus?'pause':'resume'}}</button>
<br />
<button class="button" @click="remove" >remove</button>
<br />
<!-- <button class="button" @click="reduceFramerate">reduceFramerate</button>-->
</div>
</div>
</template>
<script>
import Spineplayer3_7 from 'spineplayer/build/SpinePlayer3_7'
import Spineplayer3_8 from 'spineplayer/build/SpinePlayer3_8'
let body1 = null
let body2 = null
export default {
name: 'spinePlayer',
data(){
return{
// true play false pause
body1Loaded: false,
body2Loaded: false,
playStatus:true,
}
},
mounted() {
let spine3_7 = {"png":"https://qnyedu-hz.cdn.ipalfish.com/edu/c/spine/4edfacc16e591766e6823c93e2cdcfe1.png","json":"https://qnyedu-hz.cdn.ipalfish.com/edu/c/spine/c364f15d96e3e865a40948f14530a10e.json","atlas":"https://qnyedu-hz.cdn.ipalfish.com/edu/c/spine/b8e08876829123eed516465db61c4bdc.atlas"}
let spine3_8 = {"png":"https://qnyedu-hz.cdn.ipalfish.com/edu/test/5ebe2ed8a166ad042e6534461667af47.png","json":"https://qnyedu-hz.cdn.ipalfish.com/edu/test/33e018e05e9a801a21af35f1be887a00.json","atlas":"https://qnyedu-hz.cdn.ipalfish.com/edu/test/bb870c027a9b45d4e7171312937615d4.atlas"}
body1 = new Spineplayer3_7({
parent: this.$refs['3-7'],
pngUrl:spine3_7.png,
atlasUrl:spine3_7.atlas,
jsonUrl:spine3_7.json,
reduceFramerate:true,
})
body1.on('loaded',()=>{
this.body1Loaded = true
console.log(body1.getAnimationList())
body1.play('2')
})
body2 = new Spineplayer3_8({
parent: this.$refs['3-8'],
pngUrl:spine3_8.png,
atlasUrl:spine3_8.atlas,
jsonUrl:spine3_8.json,
reduceFramerate:true,
})
body2.on('loaded',()=>{
this.body2Loaded = true
console.log(body2.getAnimationList())
body2.play('1')
})
},
methods:{
reduceFramerate(){
console.log('reduceFramerate');
},
remove(){
if(body1 && body2){
body1.remove();
body1 = null;
body2.remove();
body2 = null;
}
},
changeStatus(){
if(this.playStatus){
body1.pause()
body2.pause()
}else {
body1.resume()
body2.resume()
}
this.playStatus = !this.playStatus;
}
}
}
</script>
<style scoped>
.button{
min-width: 5rem;
}
.wrap{
display: flex;
justify-content: space-around;
}
.dev{
border: 1px dashed;
position: relative;
width: 300px;
height: 300px;
}
</style>