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

北京网站建设的公天津建站方案

北京网站建设的公,天津建站方案,做校园网站 怎么备案,公司装修报价目录 见缝插针UI脚本针脚本球脚本心得_旋转心得_更改父节点心得_缓动动画成品展示图 见缝插针 本人只是看了老师的大纲,中途不明白不会的时候再去看的视频 所以代码可能与老师代码有出入 SIKI_学院_点击跳转 UI脚本 import { _decorator, Camera, color, Component, directo…

目录

  • 见缝插针
    • UI脚本
    • 针脚本
    • 球脚本
    • 心得_旋转
    • 心得_更改父节点
    • 心得_缓动动画
    • 成品展示图

见缝插针

本人只是看了老师的大纲,中途不明白不会的时候再去看的视频
所以代码可能与老师代码有出入
SIKI_学院_点击跳转

UI脚本

import { _decorator, Camera, color, Component, director, instantiate, Label, math, Node, Prefab, tween } from 'cc';
const { ccclass, property } = _decorator;@ccclass('ts_ui')
export class ts_ui extends Component {static inthis : ts_uistatic getinthis() : ts_ui {return this.inthis}@property(Prefab) pin : Prefab = null@property(Node) cam : Node = nullpin_num : number = 0    //  是否生成pin@property(Label) ui_fen : Label = nullfen : number = 0@property(Camera) camera : Camera = null@property(Node) but : Node = nullstart() {ts_ui.inthis = thisthis.schedule(this.on_rate,1)this.on_fen(0)}update(deltaTime: number) {}on_rate(){if (this.pin_num == 1){return}  //  是否生成const p = instantiate(this.pin)this.cam.addChild(p)p.setPosition(0 , -640)this.pin_num = 1}on_fen(num : number){this.fen += numthis.ui_fen.string = this.fen.toString()}on_end(){this.but.active = truethis.on_anim()this.scheduleOnce(function(){director.pause()},1)}on_anim(){  //  结束缓动动画函数let new_col = new math.Color()new_col.r = 60new_col.g = 5new_col.b = 5new_col.a = 255tween(this.camera).to(1 , {orthoHeight : 450 , clearColor : new_col}).start()}on_reset(){director.resume()director.loadScene(`s1`)}
}

针脚本

import { _decorator, Collider2D, Component, Contact2DType, Input, input, Node } from 'cc';
import { ts_circle } from './ts_circle';
import { ts_ui } from './ts_ui';
const { ccclass, property } = _decorator;@ccclass('ts_pin_s')
export class ts_pin_s extends Component {move_sp : number = -2   //  -2刚生成时 -1等待发射 0发射 1完成碰撞start() {const col = this.getComponent(Collider2D)if (col){col.on(Contact2DType.BEGIN_CONTACT,this.on_bc,this)}   //  开启碰撞else {console.log(`针头 开启碰撞异常`)}input.on(Input.EventType.TOUCH_END , this.on_te , this)     //  开启触摸}on_bc (me : Collider2D , oth : Collider2D){console.log(`针头碰撞`,oth.name)if (oth.name == `Circle<CircleCollider2D>`){const pw = this.node.getWorldPosition()const rw = this.node.getWorldRotation()const cir = ts_circle.getinthis()this.node.setParent(cir.node)       //  更新父节点this.node.setWorldPosition(pw)this.node.setWorldRotation(rw)this.move_sp = 1const ui = ts_ui.getinthis()ui.pin_num = 0ui.on_fen(1)}if (oth.name == `Pin<BoxCollider2D>`){ts_ui.getinthis().on_end()}}on_te(){if (this.move_sp == -1){this.move_sp = 0}}update(deltaTime: number) {this.move(deltaTime)}move(deltaTime: number){if (this.move_sp >= 1){return}const pos = this.node.getPosition()if (this.move_sp == -2){if (pos.y <= -500){this.node.setPosition(pos.x , pos.y + deltaTime * 500)}      //  新生成速度else {this.move_sp = -1}}if (this.move_sp == -1){return}if (this.move_sp == 0){this.node.setPosition(pos.x , pos.y + deltaTime * 1000)}      //  发射速度}
}

move 函数处于性能考虑
应该在条件判断成立时 返回的,不应该多个IF轮流判定

球脚本

import { _decorator, CircleCollider2D, Collider2D, Component, Contact2DType, Input, Node } from 'cc';
const { ccclass, property } = _decorator;@ccclass('ts_circle')
export class ts_circle extends Component {static inthis : ts_circlestatic getinthis() : ts_circle {return this.inthis}start() {ts_circle.inthis = thisconst col = this.getComponent(Collider2D)if (col){col.on(Contact2DType.BEGIN_CONTACT,this.on_bc,this)}else {console.log(`球 开启碰撞异常`)}}on_bc(me : Node , oth : Node){console.log(`球 碰撞` , oth.name)}update(deltaTime: number) {this.node.angle += 2if (this.node.angle >= 360){this.node.angle = 0}}
}

心得_旋转

在这里插入图片描述
项目设置 > 功能裁剪 > 2D物理系统 > 内置2D物理系统
在不改内置的情况下

this.node.angle += 2    //  旋转角度速度

球旋转会卡住不动,取消刚体组件也可以使其正常旋转,但碰撞就会有点麻烦

心得_更改父节点

在变更父节点的时候,子节点的位置和角度会被重置
不想重置,就需要记录之前的位置和角度,更换后再设置回来

        if (oth.name == `Circle<CircleCollider2D>`){const pw = this.node.getWorldPosition()const rw = this.node.getWorldRotation()const cir = ts_circle.getinthis()this.node.setParent(cir.node)       //  更新父节点this.node.setWorldPosition(pw)this.node.setWorldRotation(rw)this.move_sp = 1const ui = ts_ui.getinthis()ui.pin_num = 0ui.on_fen(1)}

心得_缓动动画

还没有仔细研究,看了老师的视频,依葫芦画瓢
但看使用情况来看,以下是个人理解
tween 传入缓动组件
to 传入 1缓动执行时间 2组件需要缓动变更的属性
start 开始

    on_anim(){  //  结束缓动动画函数let new_col = new math.Color()new_col.r = 60new_col.g = 5new_col.b = 5new_col.a = 255tween(this.camera).to(1 , {orthoHeight : 450 , clearColor : new_col}).start()}

成品展示图

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述


文章转载自:

http://ql7I0rp2.gssqz.cn
http://oDjIkvoP.gssqz.cn
http://OV4o7mJD.gssqz.cn
http://mwgi9Rp4.gssqz.cn
http://WHxu1CxB.gssqz.cn
http://2DwPnlh7.gssqz.cn
http://SgO1tRrk.gssqz.cn
http://cOCCdlgv.gssqz.cn
http://isIjzYbl.gssqz.cn
http://Jzw7L4Gr.gssqz.cn
http://p64QGQCE.gssqz.cn
http://1osev1fn.gssqz.cn
http://50dAJrU3.gssqz.cn
http://pwDhHvox.gssqz.cn
http://BKVd3xVJ.gssqz.cn
http://D8qUd2ZK.gssqz.cn
http://u5rDd3r2.gssqz.cn
http://11ms9nvJ.gssqz.cn
http://lkRvEVTK.gssqz.cn
http://j4AKCfIH.gssqz.cn
http://whqdUVkf.gssqz.cn
http://EqoTb6mG.gssqz.cn
http://J5yHanQN.gssqz.cn
http://DoN5zVgz.gssqz.cn
http://4oAxXWNb.gssqz.cn
http://wncYxm7y.gssqz.cn
http://CGqZ6klq.gssqz.cn
http://ifXGkEtS.gssqz.cn
http://7s4MVmiL.gssqz.cn
http://bURHsWp7.gssqz.cn
http://www.dtcms.com/wzjs/689515.html

相关文章:

  • 龙岗网站优化公司案例Wordpress网站仿站
  • 公众号和网站小城镇建设期刊网站
  • 电子商务网站平台建设策划社区网站优化
  • 哪些企业必须用网站湖州高端网站设计
  • 排名前十的网站盐城公司网站建设电话
  • 我的世界做壁纸网站企业网站代备案
  • 百度aipage智能建站腾讯云域名管理
  • 余姚网站seo运营用front page2003做网站的导航条
  • 网站定制营销自建网站怎么做后台管理系统
  • 漯河网站建设e注册网站手机号收验证码
  • iis7搭建aspx网站crm系统解决方案
  • 在什么网站上做自媒体商标与logo的区别
  • 网站怎么下载视频网络网站建
  • 最新网站查询大连甘井子区
  • 伊利网站建设水平评价在线购物网站设计
  • 网站域名跳转是怎么做的招聘模板制作app
  • 株洲网站建设企业pageadmin安装教程
  • 朝阳区网站建设君和广州海珠建网站
  • 最好的科技资讯网站银川网站建设报价
  • 校园网站建设价格后台网站建设招聘
  • 哈尔滨网站关键字优化电子商务专业就业前景如何
  • 建设银行吴中支行网站工厂关键词网络推广
  • 珠海网站建设咨询seo排名软件哪个好
  • 建设一个广告联盟的网站网站建设费可以计入办公费用么
  • 太原制作公司网站seo关键词排名工具
  • 虚拟主机网站建设步骤?wordpress商城主题
  • 网站开发的技术内容wordpress页面文字的样式
  • 网站优化方案哪里做网站一套一百
  • 优秀的网站建设给个做的网站吗
  • 好的网站收入wordpress拼图