【Cocos TypeScript 零基础 16.1】

目录

  • FlappyBird
    • 背景
    • 其他
    • 心得_刚体
    • audio部分

FlappyBird

本人没有按照老师的做法去做,大体差不多,
当然老师做的更精细,有些不会的还是参考老师的方法
参考部分

  1. 小鸟如何像真实物体一样的重力效果
  2. 点击如何使小鸟飞翔

省略部分
3. 小鸟多动画(飞机大战其实有做,单纯偷懒)
4. 小鸟死亡滚动(猜想是给一个边缘力使其旋转,或代码直接使其旋转)
5. 中间区域碰撞(我用的是计时的方法,老师用碰撞方法,碰撞不阻碍移动)
6. UI界面的省略(UI界面省略部分)
7. 奖牌的发放(只是多个判断就能实现,所以懒得做了)

增加部分
8. 音频控制

背景

我的背景部分包含了很多
【Cocos TypeScript 零基础 16.1】_第1张图片
目之所及全是背景
【Cocos TypeScript 零基础 16.1】_第2张图片
光是绑定在BG上的组件就有很多,还没有参数,参数都是在代码里自己改
废话不多说,上代码

import {
    _decorator, AudioClip, AudioSource, Component, director, instantiate, Label, Node, Prefab, randomRangeInt, Slider } from 'cc';
import {
    AudioMgr } from './AudioMgr';
import {
    ts_bird_att } from './ts_bird_att';
const {
    ccclass, property } = _decorator;

@ccclass('ts_bg')
export class ts_bg extends Component {
   
    speed : number = 100    //  背景移动速度
    kj : number = 160       //  逃跑初始空间
    pi_rate : number = 2    //  障碍物生成时间间隔
    pi_time : number = 0    //  临时存储时间
    fen : number = -6
    end : boolean = false   //  游戏是否结束,控制背景移动
    set_bol : boolean = false

    @property(Node) ui : Node = null
    @property(Node) bg_day_1 : Node = null
    @property(Node) bg_day_2 : Node = null
    @property(Node) land_1 : Node = null
    @property(Node) land_2 : Node = null
    @property(Prefab) pipe_up : Prefab = null  //  理论上为了减小安装包大小材质要尽可能复用
    @property(Prefab) pipe_dw : Prefab = null

    bg_arr : Node[] = []
    @property(AudioClip) aud_bg : AudioClip = null
    @property(AudioClip) aud_end : AudioClip = null
    @property(Label) fen_up : Label = null
    @property(Label) fen_now : Label = null
    @property(Node) ui_set : Node = null
    

你可能感兴趣的:(Cocos,TypeScript,零基础,typescript,javascript,前端,cocos2d)