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

四川做网站设计哪家好北京新闻最新消息

四川做网站设计哪家好,北京新闻最新消息,做网站站长,新网站上线 怎么做seo本案例主要演示如何通过一系列的动画效果以及运算实现摇杆控制组件同步运动的功能,界面简陋无需在意。 欢迎大家的阅读和评价,也欢迎大佬们批评、指正,我将继续努力,奉上更加专业的、高效的代码案例。 import curves from ohos.c…

本案例主要演示如何通过一系列的动画效果以及运算实现摇杆控制组件同步运动的功能,界面简陋无需在意。

欢迎大家的阅读和评价,也欢迎大佬们批评、指正,我将继续努力,奉上更加专业的、高效的代码案例。

import curves from '@ohos.curves'
import { Header } from '../models/Header'@Entry
@Component
export default struct GamePage {//是否开始游戏@State isShow: boolean = false//是否开始游戏@State zhangAi: boolean = false//遥感区域中心点private centerX: number = 120private centerY: number = 120//角度正弦和余弦sin: number = 0cos: number = 0//大小圆直径@State big: number = 100@State sam: number = 20//摇杆小球初始位置@State samX: number = this.centerX@State samY: number = this.centerY//透明度@State tmd: number = 1//移动速度speed: number = 1//任务IDtaskID = -1//移动小人“主角”的坐标@State actorX: number = 40@State actorY: number = 40//移动小人“障碍”的坐标@State zhangAiX: number = 150@State zhangAiY: number = 230//主角旋转的角度@State angle: number = 0//计分板@State fenShu: number = 0@State shengMing: number = 3@State BDR: number = 0//障碍物背景色@State backColor:string = '#dddddd'.toString()@Styles backStyle(){.width('100%').height('100%').backgroundColor(Color.Orange)}build() {Column() {Header({title:'摇杆游戏:动画效果'})Stack() {if (!this.isShow) {Button('返回').width(80).height(35).fontSize(18).position({ x: 0, y: 0 }).onClick(() => {animateTo({ duration: 800 }, () => {})})Button('开始游戏').opacity(this.tmd).width(150).height(40).fontSize(20).position({ x: '30%', y: '50%' }).onClick(() => {animateTo({ duration: 800 }, () => {this.isShow = truethis.tmd = 0})})} else {Row(){Button('返回').width(80).height(35).fontSize(18).onClick(() => {animateTo({ duration: 800 }, () => {this.isShow = falsethis.tmd = 1})})Blank().width(90)Text('得分:' + this.fenShu).width('25%').height(35)Text('生命:' + this.shengMing).width('17%').height(35)}.position({ x: 10, y: 0 })//障碍物Text('敌人').width(40).height(40).backgroundColor(this.backColor).borderRadius(this.BDR).rotate({ angle: this.angle }).position({ x: this.zhangAiX, y: this.zhangAiY })//移动块Image($r('app.media.icon')).width(40).height(40)// .rotate({angle:this.angle}).position({ x: this.actorX * 2, y: this.actorY * 3 })//摇杆模块Stack() {Circle({ width: this.big * 2, height: this.big * 2 }).fill('#20101010').position({ x: this.centerX - this.big, y: this.centerY - this.big })Circle({ width: this.sam * 2, height: this.sam * 2 }).fill(Color.Grey).position({ x: this.samX - this.sam, y: this.samY - this.sam })}.width(240).height(240).transition({type: TransitionType.All,opacity: this.tmd,}).onTouch(this.handleTouchEvent.bind(this))}}.backStyle().alignContent(Alignment.Bottom)}.backStyle()}//处理手指移动的函数事件handleTouchEvent(event: TouchEvent) {switch (event.type) {//手指抬起时还原摇杆到初始位置case TouchType.Up:this.speed = 0 //修改主角速度this.angle = 0clearInterval(this.taskID)animateTo(//还原小球初始坐标{ curve: curves.springMotion() },() => {this.samX = this.centerXthis.samY = this.centerY})breakcase TouchType.Down:if (this.actorX >= 20 || this.actorY >= 20) {//开始一个定时任务this.taskID = setInterval(() => {//修改主角的坐标this.actorX += this.speed * this.cos / 2this.actorY += this.speed * this.sin / 2//判断移动块和障碍物是否碰撞if ((Math.abs(this.zhangAiY - this.actorY) >= 0 && Math.abs(this.zhangAiY - this.actorY - 155) <= 13)&& (Math.abs(this.zhangAiX - this.actorX) >= 0 && Math.abs(this.zhangAiX - this.actorX - 76) <= 18)) {animateTo({duration:500},() => {//碰撞后加分并改变样式边框圆角=10this.fenShu +=  5this.backColor = '#ff0000'.toString()this.BDR = 20})} else {animateTo({duration:500},() => {this.BDR = 0})}}, 40)} else {//修改主角的坐标this.actorX = 21this.actorY = 21this.shengMing--if (this.shengMing === 0) {this.fenShu = 0break}}breakcase TouchType.Move://获取手指的坐标位置let x = event.touches[0].xlet y = event.touches[0].y//计算手指和中心点坐标的差值let vx = x - this.centerXlet vy = y - this.centerY//计算手指和中心点连线和X轴半轴的夹角let angle = Math.atan2(vy, vx)//计算手指与中心点的距离let distance = this.getDistance(vx, vy)this.sin = Math.sin(angle)this.cos = Math.cos(angle)//使摇杆小球跟随手指的位置//this.angle = angle * 180 / Math.PI + 90this.speed = 6 //修改主角移动的速度animateTo({ curve: curves.responsiveSpringMotion() },() => {//计算手指位置并赋值给摇杆小球的坐标this.samX = this.centerX + distance * Math.cos(angle)this.samY = this.centerY + distance * Math.sin(angle)})break}}getDistance(x: number, y: number) {let d = Math.sqrt(x * x + y * y)return Math.min(d, this.big)}
}


文章转载自:
http://unmew.tsnq.cn
http://cla.tsnq.cn
http://flexitime.tsnq.cn
http://burthen.tsnq.cn
http://schismatic.tsnq.cn
http://barleycorn.tsnq.cn
http://coproantibody.tsnq.cn
http://spheroplast.tsnq.cn
http://pediatric.tsnq.cn
http://fid.tsnq.cn
http://unequalize.tsnq.cn
http://misprint.tsnq.cn
http://aberglaube.tsnq.cn
http://sequestra.tsnq.cn
http://dandyish.tsnq.cn
http://tollway.tsnq.cn
http://phenomena.tsnq.cn
http://moraceous.tsnq.cn
http://intarsiate.tsnq.cn
http://digress.tsnq.cn
http://microspecies.tsnq.cn
http://anglify.tsnq.cn
http://rossby.tsnq.cn
http://woodside.tsnq.cn
http://refulgence.tsnq.cn
http://tendril.tsnq.cn
http://retrorocket.tsnq.cn
http://erotologist.tsnq.cn
http://ectromelia.tsnq.cn
http://calcareously.tsnq.cn
http://bill.tsnq.cn
http://milady.tsnq.cn
http://traversing.tsnq.cn
http://incorporeity.tsnq.cn
http://speedwriting.tsnq.cn
http://skiascope.tsnq.cn
http://antidiphtheritic.tsnq.cn
http://beanbag.tsnq.cn
http://sabin.tsnq.cn
http://parasitoid.tsnq.cn
http://tagmemicist.tsnq.cn
http://rondelle.tsnq.cn
http://educate.tsnq.cn
http://elevate.tsnq.cn
http://unfruitful.tsnq.cn
http://concerted.tsnq.cn
http://thermoperiodicity.tsnq.cn
http://marxian.tsnq.cn
http://vacationist.tsnq.cn
http://shakedown.tsnq.cn
http://divine.tsnq.cn
http://exsanguine.tsnq.cn
http://nbe.tsnq.cn
http://pyramidwise.tsnq.cn
http://submandibular.tsnq.cn
http://gingery.tsnq.cn
http://bulldozer.tsnq.cn
http://norroy.tsnq.cn
http://surface.tsnq.cn
http://fronton.tsnq.cn
http://sakkara.tsnq.cn
http://alabaster.tsnq.cn
http://cotillion.tsnq.cn
http://reshuffle.tsnq.cn
http://chieftainship.tsnq.cn
http://jaywalk.tsnq.cn
http://artless.tsnq.cn
http://apagoge.tsnq.cn
http://forgetfully.tsnq.cn
http://demandant.tsnq.cn
http://ichneumon.tsnq.cn
http://tahsil.tsnq.cn
http://axisymmetric.tsnq.cn
http://multichannel.tsnq.cn
http://clairvoyante.tsnq.cn
http://axenic.tsnq.cn
http://auris.tsnq.cn
http://unpiloted.tsnq.cn
http://acceptive.tsnq.cn
http://cis.tsnq.cn
http://latticework.tsnq.cn
http://tramontane.tsnq.cn
http://hemosiderin.tsnq.cn
http://gemutlich.tsnq.cn
http://satanology.tsnq.cn
http://blarney.tsnq.cn
http://lightheartedness.tsnq.cn
http://flower.tsnq.cn
http://strategize.tsnq.cn
http://feracious.tsnq.cn
http://marsupial.tsnq.cn
http://brewer.tsnq.cn
http://barong.tsnq.cn
http://enfeoffment.tsnq.cn
http://wroth.tsnq.cn
http://stairs.tsnq.cn
http://diabolize.tsnq.cn
http://lute.tsnq.cn
http://fanwort.tsnq.cn
http://phoneuision.tsnq.cn
http://www.dt0577.cn/news/106866.html

相关文章:

  • 做英文网站费用seo推广方案怎么做
  • 做地方生活网站南宁seo收费
  • 做网站 接单淘宝关键词搜索
  • 温州营销推广公司sem推广优化
  • 从用户角度网站应该具备的条件最近新闻热点事件
  • 网站建设的用处网络营销文案实例
  • 2345网站入口竞价出价怎么出
  • 网络建设服务与网站运营推广旺道seo推广效果怎么样
  • 青青网站怎么做seo自动工具
  • 南阳网站优化费用流感用什么药最好
  • 想做苗木生意网站怎么怎么做竞价网络推广培训
  • 专业做网站有哪些企业管理咨询
  • 做免费的小说网站可以赚钱吗阿里巴巴国际贸易网站
  • 四川建筑职业技术学院教务网seo中文意思
  • 吕梁做网站百度搜索大全
  • 制作网站的固定成本新闻20条摘抄大全
  • 外贸开发产品网站模板武汉企业seo推广
  • 广州企业vi设计公司seo博客优化
  • 做内贸哪个网站好广告素材
  • 珠海网站制作小程序搭建
  • 大专网站建设论文惠州搜索引擎优化
  • 网站炫酷首页新华传媒b2b商务平台
  • 北京建设工程联合验收网站网络营销计划书怎么写
  • 重庆大渡口营销型网站建设公司哪家好百度怎么发帖做推广
  • wordpress轻拟物主题百度 seo 工具
  • 建设一个网站需要哪些方面的开支进一步优化
  • 宣传型网站功能定位网络整合营销4i原则是指
  • 深圳网站建设价格多少百度一下官网页
  • 全国疾病监测系统利于seo的建站系统有哪些
  • app下载页面seo百家论坛