增加显示英雄出现前的光效

This commit is contained in:
zhl 2021-12-29 20:18:12 +08:00
parent df56742ee7
commit baf32f0dd3
3 changed files with 62 additions and 2 deletions

View File

@ -0,0 +1,56 @@
<template>
<div class="home_hero">
<spine-view class="hero-anim" :data="data" ></spine-view>
<spine-view class="effect-anim" :data="effectData" ></spine-view>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import SpineView from '@/components/main/SpineView.vue'
import { ISpineData } from '@/utils/SpineRender'
declare module 'vue/types/vue' {
interface Vue {
data: ISpineData
}
}
// TODO:: ,
@Component({
name: 'HomeHero',
props: ['data'],
components: {
SpineView
}
})
export default class extends Vue {
get effectData() {
return {
id: `effect_${this.data.id}`,
skelName: 'guang_texiao',
animName: 'animation',
repeat: false
}
}
}
</script>
<style lang="scss" scoped>
.home_hero{
position: relative;
}
.hero-anim {
width: 400px;
height: 800px;
margin-left: -90px;
margin-right: -90px;
}
.effect-anim {
left:0;
top: 0;
margin-left: -80px;
margin-top: 50px;
width: 400px;
height: 800px;
position: absolute;
}
</style>

View File

@ -12,7 +12,7 @@
</div> </div>
<div class="home_right_panel"> <div class="home_right_panel">
<div class="spine-list"> <div class="spine-list">
<spine-view class="hero-anim" v-for="hero in heros" :data="hero" :key="hero.id"></spine-view> <home-hero class="hero-anim" v-for="hero in heros" :data="hero" :key="hero.id"></home-hero>
</div> </div>
</div> </div>
</section> </section>
@ -22,10 +22,12 @@
import { Component, Vue } from 'vue-property-decorator' import { Component, Vue } from 'vue-property-decorator'
import SpineView from '@/components/main/SpineView.vue' import SpineView from '@/components/main/SpineView.vue'
import { ISpineData } from '@/utils/SpineRender' import { ISpineData } from '@/utils/SpineRender'
import HomeHero from '@/components/main/HomeHero.vue'
@Component({ @Component({
name: 'HomeSection', name: 'HomeSection',
components: { components: {
HomeHero,
SpineView SpineView
} }

View File

@ -21,6 +21,7 @@ export class SpineRender {
private shapes private shapes
private assetManager private assetManager
private scale = 1.5 private scale = 1.5
private repeat = true
constructor(canvas: HTMLCanvasElement) { constructor(canvas: HTMLCanvasElement) {
const config = { alpha: true } const config = { alpha: true }
@ -46,6 +47,7 @@ export class SpineRender {
init({ skelName, animName, scale, repeat }: ISpineData) { init({ skelName, animName, scale, repeat }: ISpineData) {
this.skelName = skelName this.skelName = skelName
this.animName = animName this.animName = animName
this.repeat = repeat
this.scale = scale || this.scale this.scale = scale || this.scale
// Create a simple shader, mesh, model-view-projection matrix and SkeletonRenderer. // Create a simple shader, mesh, model-view-projection matrix and SkeletonRenderer.
this.mvp.ortho2d(0, 0, this.canvas.width - 1, this.canvas.height - 1) this.mvp.ortho2d(0, 0, this.canvas.width - 1, this.canvas.height - 1)
@ -90,7 +92,7 @@ export class SpineRender {
// Create an AnimationState, and set the initial animation in looping mode. // Create an AnimationState, and set the initial animation in looping mode.
const animationStateData = new spine.AnimationStateData(skeleton.data) const animationStateData = new spine.AnimationStateData(skeleton.data)
const animationState = new spine.AnimationState(animationStateData) const animationState = new spine.AnimationState(animationStateData)
animationState.setAnimation(0, initialAnimation, true) animationState.setAnimation(0, initialAnimation, self.repeat)
animationState.addListener({ animationState.addListener({
start: function(track: spine.TrackEntry) { start: function(track: spine.TrackEntry) {
console.log('Animation on track ' + track.trackIndex + ' started') console.log('Animation on track ' + track.trackIndex + ' started')