当前位置: 首页 > news >正文

做网站如何分页免费开店的电商平台

做网站如何分页,免费开店的电商平台,网站301检测工具,拖式网站建设现在游戏基本能完了, 飞机能发射子弹,打了敌机,敌机也能炸; 接下来要做计分了; 步骤: 搞出一个lable让lable显示炸了多少飞机 开搞: ①创建一个Lable标签 ② root.ts文件 添加 property(Label) player_score: Label; // 标签属性 标签绑定 ③ 代码添加 注册 然后回调 contac…

现在游戏基本能完了, 飞机能发射子弹,打了敌机,敌机也能炸;
接下来要做计分了;
步骤:

  1. 搞出一个lable
  2. 让lable显示炸了多少飞机
    开搞:
    ①创建一个Lable标签
    在这里插入图片描述
    ② root.ts文件
    添加
    @property(Label) player_score: Label; // 标签属性
    标签绑定
    在这里插入图片描述
    ③ 代码添加
    注册 然后回调
    contactListener() {// 注册全局碰撞回调函数if (PhysicsSystem2D.instance) {PhysicsSystem2D.instance.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);}}// 全局的碰撞检测onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {// 只在两个碰撞体开始接触时被调用一次//console.log('Main_ROOT -> onBeginContact');console.log('selfCollider : ' + selfCollider.name);console.log('otherCollider : ' + otherCollider.name);if (selfCollider.name.includes('enemy_prefab') && otherCollider.name.includes('playerBullet_prefab')) {this.score++;this.player_score.string = "当前得分: " + this.score;}if (selfCollider.name.includes('player_node') && otherCollider.name.includes('enemy_prefab')) {this.player_score.string = '被炸了';}

root.ts完整代码

import { _decorator, Collider2D, Component, Contact2DType, instantiate, IPhysics2DContact, Label, Node, PhysicsSystem2D, Prefab } from 'cc';
const { ccclass, property } = _decorator;@ccclass('root')
export class root extends Component {@property(Node) enemy_node: Node;   // 添加属性 以便在代码中引用 敌人节点@property(Prefab) enemy_prefab: Prefab;   // 添加属性 以便在代码中 动态生成 敌人@property(Label) player_score: Label;   // 添加属性 以便在代码中 动态生成 敌人private score = 0;start() {this.createEnemies(); //使用定时器生成敌机this.contactListener();}update(deltaTime: number) {}contactListener() {// 注册全局碰撞回调函数if (PhysicsSystem2D.instance) {PhysicsSystem2D.instance.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);}}// 全局的碰撞检测onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {// 只在两个碰撞体开始接触时被调用一次//console.log('Main_ROOT -> onBeginContact');console.log('selfCollider : ' + selfCollider.name);console.log('otherCollider : ' + otherCollider.name);if (selfCollider.name.includes('enemy_prefab') && otherCollider.name.includes('playerBullet_prefab')) {this.score++;this.player_score.string = "当前得分: " + this.score;}if (selfCollider.name.includes('player_node') && otherCollider.name.includes('enemy_prefab')) {this.player_score.string = '被炸了';}
}createEnemies() {this.schedule(() => {this.createOneEnemy();}, 1);}// 创建一个敌机createOneEnemy() {// console.log("createOneGold !");const enemyPrefab = instantiate(this.enemy_prefab);   // 实例化一个对象 (动态生成)this.enemy_node.addChild(enemyPrefab);     // 将对象 添加到某个 节点内let x = (Math.random() * 360)   // random() 0-360 enemyPrefab.setPosition(180 - x, 350);  // 设置敌机的Y坐标}
}

剩下的就是结束场景
创建一个gameOver_scene
一个GameOver_node
一个retry_button
还有俩脚本retry_button.ts
GameOver.ts
绑定
在这里插入图片描述

在这里插入图片描述
最重要的是这里
在这里插入图片描述
retry_button.ts脚本文件

import { _decorator, Component, director, Node } from 'cc';
const { ccclass, property } = _decorator;@ccclass('ButtonRetry')
export class ButtonRetry extends Component {start() {}update(deltaTime: number) {}// 跳转到主场景gotoMainScene() {director.loadScene("main_scene");}
}

GameOver .ts

import { _decorator, Component, director, Label, Node } from 'cc';const { ccclass, property } = _decorator;@ccclass('GameOver')
export class GameOver extends Component {@property(Label) ScoreLabel: Label;   // 添加属性 以便在代码中 修改得分start() {this.ScoreLabel.string = "游戏结束";}update(deltaTime: number) {}
}

root.ts脚本中需要添加

  director.loadScene("gameOver_scene"); // 跳转到结束场景

这一章写的有点糙, 先这样吧, 这些天有点累了
后面的章节是小游戏部署到微信小游戏平台;
和登陆获取信息和跟后台交互

http://www.mmbaike.com/news/104754.html

相关文章:

  • 做影视网站的软件网络营销竞价推广
  • 知己图书网站建设策划书wordpress网站建设
  • 湘潭网站优化nba最新排名
  • 现在可以做网站么seo网页优化平台
  • 企业网站建设制作设计哪家最专业获客软件
  • 一级a做爰片阿v祥仔网站百度网站提交
  • 三五互联网站后台管理培训
  • python官网下载安装女生seo专员很难吗为什么
  • 南昌建设银行网站网站推广联盟
  • 优化系统是什么意思长沙优化科技有限公司正规吗
  • 杨浦区建设和交通委员会官方网站成都正规搜索引擎优化
  • 网站前置审批文件天津优化加盟
  • 河北网站设计推荐柚米科技房地产营销策略有哪些
  • 中央纪委网站 举报 要这么做才有效年度关键词有哪些
  • 日照开发区建设局网站如何推广普通话的建议6条
  • wordpress 2019主题武汉网站seo公司
  • 打赏网站怎么建设网站收录情况查询
  • 扫黄除恶网站构造结构怎么做搜索引擎营销的成功案例
  • 国外做自动化网站公司网址
  • 网站建设 云南营销型网站建设推广
  • 政府网站建设发展前景网络运营培训班
  • 湖南建设网站原创代写文章平台
  • 青岛手机网站建设青岛网站建设公司电话
  • 网站建设优化培训百度投诉中心24人工 客服电话
  • 河北省招标投标信息网超级推荐的关键词怎么优化
  • 网站推广排名报价中国没有限制的搜索引擎
  • 布吉医院网站建设温州seo顾问
  • wordpress站点标题看不到2022十大网络营销案例
  • 建设英文网站公司宣传软文
  • 网站开发技术方案与实施百度seo报价