mario jumper

在线测试地址:http://www.ifiero.com/uploads/phaserjs3/jumper/

空格键:轻按:跳低 ,长按:跳高
键盘:--> 向右 , <-- 向左

请确保已打开电脑的音乐开关

var config = {type: Phaser.AUTO,width: 650,height: 450, parent: "ifierocom", physics: { default: 'arcade', arcade: { gravity: { y: 350 }, debug: false } }, scene: { preload: preload, create: create, update: update } }; var player; var stars; var bombs; var platforms; var cursors; var score = 0; var gameOver = false; var scoreText; // var jumpTimer = 0; var game = new Phaser.Game(config); var isSmall = true; // small jump music var isSuper = true; // super jump music function init() { this.jumpTimer = 0; this.isCanJump = false; this.isCanLeft = false; this.isCanRight = false; this.isCanStand = true; this.velocityL = 0; this.velocityR = 0; } function preload() { this.load.image('sky', 'assets/sky.png'); this.load.image('ground', 'assets/platform.png'); this.load.image('star', 'assets/star.png'); this.load.image('bomb', 'assets/bomb.png'); // this.load.spritesheet('dude', 'assets/dude.png', { // frameWidth: 32, // frameHeight: 48 // }); this.load.spritesheet('mario', 'assets/mario_mario.png', { frameWidth: 16, frameHeight: 16, margin: 1, spacing: 1 }); //music: small this.load.audio('jumpSmall', 'assets/audio/JumpSmall.mp3'); //music: super this.load.audio('jumpSuper', 'assets/audio/JumpSuper.mp3'); //music: super this.load.audio('coin', 'assets/audio/Coin.mp3'); } function create() { this.spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); // A simple background for our game this.add.image(400, 300, 'sky'); // The platforms group contains the ground and the 2 ledges we can jump on platforms = this.physics.add.staticGroup(); // Here we create the ground. // Scale it to fit the width of the game (the original sprite is 400x32 in size) platforms.create(400, 568, 'ground').setScale(2).refreshBody(); // Now let's create some ledges platforms.create(600, 400, 'ground'); platforms.create(50, 250, 'ground'); platforms.create(750, 220, 'ground'); // The player and its settings // player = this.physics.add.sprite(100, 450, 'dude'); player = this.physics.add.sprite(100, 450, 'mario', 0); player.setScale(2.5); // Player physics properties. Give the little guy a slight bounce. player.setBounce(0.2); player.setCollideWorldBounds(true); // Our player animations, turning, walking left and walking right. this.anims.create({ key: 'run', frames: this.anims.generateFrameNumbers('mario', { start: 1, end: 3 }), frameRate: 10, repeat: -1 }); this.anims.create({ key: 'shift', frames: [{ key: 'mario', frame: 4 }], frameRate: 20 }); this.anims.create({ key: 'stand', frames: [{ key: 'mario', frame: 0 }], frameRate: 20 }); this.anims.create({ key: 'jump', frames: [{ key: 'mario', frame: 5 }], frameRate: 20 }); // Input Events cursors = this.input.keyboard.createCursorKeys(); // Some stars to collect, 12 in total, evenly spaced 70 pixels apart along the x axis stars = this.physics.add.group({ key: 'star', repeat: 11, setXY: { x: 12, y: 0, stepX: 70 } }); stars.children.iterate(function (child) { // Give each star a slightly different bounce child.setBounceY(Phaser.Math.FloatBetween(0.4, 0.8)); }); bombs = this.physics.add.group(); // The score scoreText = this.add.text(16, 16, 'score: 0', { fontSize: '32px', fill: '#000' }); scoreText.setScrollFactor(0); // Collide the player and the stars with the platforms this.physics.add.collider(player, platforms, function () { // console.log('hit ground'); // console.groupEnd(); this.isCanJump = false; }, null, this); this.physics.add.collider(stars, platforms); this.physics.add.collider(bombs, platforms); // Checks to see if the player overlaps with any of the stars, if he does call the collectStar function this.physics.add.overlap(player, stars, collectStar, null, this); this.physics.add.collider(player, bombs, hitBomb, null, this); this.cameras.main.setBounds(0, 0, 800, 600); 

转载于:https://www.cnblogs.com/apiapia/p/10057239.html

Phaser3让超级玛丽实现轻跳、高跳及加上对应的跳跃声音相关推荐

  1. 谷歌Chrome小恐龙代码(自动跳,高跳,无敌,加速)

    目录 自动跳代码 无敌代码 高跳代码(可以改括号内参数) 疾跑代码(可以改括号内参数) 大多数浏览器都有自己的彩蛋,而今天我们分享的是谷歌Chrome 谷歌小恐龙游戏是一个浏览器自带的小游戏. 断网联 ...

  2. linux 时间会跳吗,linux系统时间暂时跳跃

    此脚本将告诉您何时发生时间漂移以及进程树中的差异,如果这是由更改系统时间的进程引起的,则应该有助于识别此情况.它将打印到终端并登录到当前工作目录中的timedrift.log. #!/bin/bash ...

  3. html跳一跳小游戏,HTML5涂鸦跳跃(Doodle Jump)小游戏

    JavaScript 语言: JaveScriptBabelCoffeeScript 确定 // RequestAnimFrame: a browser API for getting smooth ...

  4. mui框架之a标签无法跳转的问题

    最近在mobile的项目中用到了mui前端框架,自己先学习了一下,感觉功能挺全,因为要开发m站,就选择用了mui的前端h5的框架,由于是第一次用到,难免会踩坑. 要实现这样一个产品的列表,由于要分页, ...

  5. 跳转指令微型计算机,哪种类型的汇编程序跳转指令最有用?

    Ira Baxter.. 5 (我已经为汇编程序编写了40多年;实际上在20世纪70年代早期设计并构建了一个生产多寄存器16位机器).真正有用的是CMP指令和指定该条件的JMP相对. 我建议你让算术指 ...

  6. 专为轻运动而生的南卡NEO全新发布,定位骨传导运动耳机新标杆!

    ​2023年3月2号,南卡正式发布了主打轻运动的全新系列产品--南卡NEO,这是继去年10月展出机皇南卡Runner Pro4后推出的NEO系列,与pro4不同的是南卡NEO对于音质上更加的偏向于轻型 ...

  7. 算法:一只青蛙一次可以跳上1级台阶,也可以跳上2级.求该青蛙跳上一个n级的台阶总共有多少种跳法.

    题目描述:一只青蛙一次可以跳上1级台阶,也可以跳上2级.求该青蛙跳上一个n级的台阶总共有多少种跳法. 青蛙每一次跳跃只有两种选择:一是再跳1级阶梯到达第n级阶梯,此时小青蛙处于第n-1级阶梯;或者再跳 ...

  8. 【UE·GamePlay篇】攀爬系统系列教程(二)——相邻墙壁飞跃、墙角拐弯、回头反向跳

    这一篇的内容对应视频教程: UE4 Climb System - Tutorial - Part 3 - Side Jumps & Corner Detection UE4 Climb Sys ...

  9. 解决请求重定向无法跳转以及页面无限循环跳转

    问题1:请求重定向无法跳转 原因:由于前台使用了一些框架,部分组件是利用的iframe来写页面的,导致后台对请求进行重定向时,前台页面无法跳转,而是在对镶嵌iframe中的页面进行跳转,无法实现在浏览 ...

最新文章

  1. 新的sublime text已经上传网盘,地址写在下面
  2. springboot redis
  3. VSFTP之不能登录
  4. OpenGL:使用FBO为渲染对象并从GPU取出存图
  5. 【7】jQuery学习——入门jQuery选择器之过滤选择器-可见性过滤选择器
  6. mysql jar jdk1.6_搭建非安装版mysql+jdk1.6+tomcat6
  7. oracle的sum函数精度问题_Excel中的这些烧脑问题,你遇到过几种?
  8. 为什么不能生成accde_原来“转换生成语言学”就是这么回事
  9. Linux Shell变量
  10. 已知背景和物体的均值方差,求最佳分割阈值
  11. Docker 之MySQL 重启,提示Error response from daemon: driver failed programming external connectivity on **
  12. SSCOM的模拟连接测试及服务器连接
  13. php 去除 bom,php 去除文件BOM头的方法
  14. 威feng网站的aes算法破解
  15. switch 大气层双系统 进入破解系统 及安装nsp nsz 格式教程
  16. SQL账户SA登录失败,提示错误:18456
  17. 在保护继承中基类的共有成员_鸡啄米:C++编程入门系列之三十八(继承与派生:派生类对基类成员的访问控制之保护继承与私有继承)...
  18. mysql 根据经纬度查询距离
  19. 《红楼梦》人物关系有多复杂?一张图帮你理清楚!
  20. 用dup2和dup产生一份file descriptor 的拷贝

热门文章

  1. fft之后求模值和相位_如何利用相位噪声测量表征时钟抖动来加速设计验证过程...
  2. Android日志[基础篇]二 Android Studio修改LogCat日志的颜色
  3. 计算机配件推荐系统论文摘要,个性化推荐系统设计
  4. Java 多线程 —— 常用并发容器
  5. JVM001_类文件结构
  6. MySQL优化建议汇总~~~
  7. IDEA:vue中缺少vue-quill-editor富文本插件
  8. python给js变量赋值_python 之 前端开发( JavaScript变量、数据类型、内置对象、运算符、流程控制、函数)...
  9. MySQL 创建用户
  10. 层次分析法之python