vue-pixijs View1

## View1
<template>
  <container
    v-for="(item,index) in ground"
    :key="index"
  >
    <sprite
      v-for="(item2,index2) in item"
      :key="index2"
      :x="item2[0]"
      :y="item2[1]+700-40*index"
      :texture="myTexture[item2[2]]"
      :frame="{x:0,y:0,width:101,height:171}"
    >
    </sprite>
  </container>
  <sprite
    :x="300"
    :y="780"
    texture="PlanetCute PNG/Character Boy.png"
    :frame="{x:0,y:0,width:101,height:171}"
    v-drag
  >
  </sprite>
  <sprite
    :x="505"
    :y="690"
    texture="PlanetCute PNG/Character Horn Girl.png"
    :frame="{x:0,y:0,width:101,height:171}"
    v-mounted="pointerdown"
  >
  </sprite>
  <sprite
    :x="585"
    :y="870"
    texture="PlanetCute PNG/Character Princess Girl.png"
    :frame="{x:0,y:0,width:101,height:171}"
    v-drag
    v-mounted="{go1,go2}"
    ref="abc"
  >
  </sprite>
  <container
    x=100
    y=500
    v-pointerdown="event"
  >2021915</container>
  <sprite
    :x="700"
    :y="700"
    texture="123.mp4"
    :frame="{x:0,y:0,width:1200,height:800}"
    v-pointerdown=pointerdown2
    v-drag
  >
  </sprite>
</template>

<script lang="ts">
import { Options, Vue } from "vue-class-component";
import { getGame } from "../game";
import { TweenLite, TweenMax } from "gsap";
import { Timeout } from "../decorators";

@Options({
  components: {},
  data() {
    return {
      tweenmax: this.$tweenmax,
      tweenlite: this.$tweenlite,
      ground: [
        [
          [0, 0, 0],
          [100, 0, 0],
          ......
        ],
        ......
      ],
      myTexture: [
        "PlanetCute PNG/Dirt Block.png",
        "PlanetCute PNG/Grass Block.png",
        "PlanetCute PNG/Stone Block.png",
        "PlanetCute PNG/Water Block.png",
        "PlanetCute PNG/Ramp South.png",
        "PlanetCute PNG/Ramp West.png",
        "PlanetCute PNG/Ramp East.png",
        "PlanetCute PNG/Rock.png",
        "PlanetCute PNG/Tree Short.png",
        "PlanetCute PNG/Wall Block.png",
        "PlanetCute PNG/Door Tall Closed.png",
        "PlanetCute PNG/Plain Block.png",
        "PlanetCute PNG/Enemy Bug.png",
        "PlanetCute PNG/Key.png",
      ],
    };
  },
  watch: {},
})
export default class Start extends Vue {
  // eslint-disable-next-line no-undef
  [x: string]: any;
  tween: any;
  state = this.play;

  public play(): void {
    //
  }
  public gameLoop(): void {
    this.state();
  }

  @Timeout(1000)
  go1(e: any) {
    TweenLite.to(e, 1, { x: 100 });
  }
  @Timeout(2000)
  go2(e: any) {
    TweenLite.to(e, 1, { y: 100 });
  }

  @Timeout(3000)
  pointerdown(e: any): void {
    TweenMax.to(e, 1, { x: 100, y: 100 });
  }

  pointerdown2(e: any) {
    if (e.texture.baseTexture.resource.source.paused) {
      e.texture.baseTexture.resource.source.play();
    } else {
      e.texture.baseTexture.resource.source.pause();
    }
  }

  event(e: any) {
    console.log(e);
  }

  mounted(): void {
    getGame().ticker.add(() => {
      this.gameLoop();
    });
  }
}
</script>

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值