phaser学习笔记:物理系统arcade基础平台

import Phaser from 'phaser'class GameScene extends Phaser.Scene { constructor() { super({ key: 'GameScene' }) // 平台 this.platforms = null // 移动的平台 this.movingPlatform = null // 游戏角色 this.player = null // 星星 this.star
摘要由CSDN通过智能技术生成
import Phaser from 'phaser'

class GameScene extends Phaser.Scene {
   
  constructor() {
   
    super({
    key: 'GameScene' })
    // 平台
    this.platforms = null
    // 移动的平台
    this.movingPlatform = null
    // 游戏角色
    this.player = null
    // 星星
    this.stars = null
    // 操作按键
    this.cursors = null
  }

  preload() {
   
    // 加载游戏素材资源
    // 基本路径
    this.load.path = 'assets/example/physics/basicPlatform/'
    // 具体文件
    this.load.image('sky', 'sky.png')
    this.load.image('ground', 'platform.png')
    this.load.image('star', 'star.png')
    this.load.spritesheet('dude', 'dude.png', {
    frameWidth: 32, frameHeight: 48 })
  }

  create() {
   
    // 添加天空背景
    // 添加进去的元素,默认origin是0.5 0.5,也就是居中的
    this.add.image(400, 300, 'sky')
    // 底部静止不动平台
    this.platforms = this.physics.add.staticGroup(
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值