Egret 贝塞尔曲线

Egret 贝塞尔曲线authoryjtx desc 贝塞尔曲线示例 拖动舞台上圆点 可以查看贝塞尔曲线不同的显示 modulegame exportclassb DisplayObjec privat

/ * @copyright www.egret.com * @author yjtx * @desc 贝塞尔曲线示例。 * 拖动舞台上圆点,可以查看贝塞尔曲线不同的显示。 */ module game { export class bezierCurve extends egret.DisplayObjectContainer { private _shape: egret.Shape; constructor() { super(); this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this); } private onAddToStage(event: egret.Event) { this._shape = new egret.Shape(); this.addChild(this._shape); this.init(); this.initGraphics(); } //初始化赋值 private initGraphics(): void { var shape: egret.Shape = this._shape; /* 本示例关键代码段开始 */ shape.graphics.lineStyle(3, 0xff0ff0); shape.graphics.moveTo(140, 400); shape.graphics.curveTo(340, 200, 480, 500); /* 本示例关键代码段结束 */ } private resetCure(): void { var shape: egret.Shape = this._shape; /* 本示例关键代码段开始 */ shape.graphics.clear(); shape.graphics.lineStyle(3, 0xff0ff0); shape.graphics.moveTo(this._startShape.x, this._startShape.y); shape.graphics.curveTo(this._control.x, this._control.y, this._anchor.x, this._anchor.y); /* 本示例关键代码段结束 */ } private _startShape: egret.Shape; private _control: egret.Shape; private _anchor: egret.Shape; private init(): void { this._startShape = this.initShape(140, 400, 0xffff00); this._control = this.initShape(340, 200, 0xff0000); this._anchor = this.initShape(480, 500, 0x000ff0); } private initShape(x: number, y: number, color: number): egret.Shape { var shape: egret.Shape = new egret.Shape(); shape.graphics.beginFill(color); shape.graphics.drawCircle(0, 0, 20); shape.graphics.endFill(); this.addChild(shape); shape.x = x; shape.y = y; shape.touchEnabled = true; shape.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onBeginHandler, this); return shape; } private drapShape: egret.Shape; private onBeginHandler(e: egret.TouchEvent): void { e.stopImmediatePropagation(); this.drapShape = 
  
    e.currentTarget; this.drapShape.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onBeginHandler, this); this.drapShape.touchEnabled = false; this.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.onMoveHandler, this); this.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.onEndHandler, this); } private onMoveHandler(e: egret.TouchEvent): void { this.drapShape.x = e.stageX; this.drapShape.y = e.stageY; this.resetCure(); } private onEndHandler(e: egret.TouchEvent): void { this.stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.onMoveHandler, this); this.stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onEndHandler, this); this.drapShape.touchEnabled = true;; this.drapShape.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onBeginHandler, this); } } } 
  

参考地址:https://developer.egret.com/cn/example/egret2d/index.html#030-graph-bezier;

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/227627.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月16日 下午8:52
下一篇 2026年3月16日 下午8:52


相关推荐

  • discuz 二次开发文章[通俗易懂]

    discuz 二次开发文章[通俗易懂]参考:Discuz!X3.2二次开发基本流程:https://blog.csdn.net/qq_35637004/article/details/81078611discuz二次开发常用技术手册代码:https://blog.csdn.net/qq_37744937/article/details/80241712DiscuzX2二次开发之数据库操作DB类:…

    2022年5月19日
    66
  • nmf java_NMF & pLSA[通俗易懂]

    nmf java_NMF & pLSA[通俗易懂]今天在围脖中看到自动化所刘康的围脖中给了一个关于NMF和pLSA对比分析的链接http://ezcodesample.com/plsaidiots/NMFPLSA.html,大体读了一下,下面用中文对文中的思想重新解释,版权归原作者AndrewPolar。一、名词解释(1)NMF,nonnegativematrixfactorization,直观理解即非负矩阵分解,通常用于矩阵填充,推荐系…

    2022年6月29日
    40
  • flex java 整合_java整合flex

    flex java 整合_java整合flex另外一种 Flex 工程增加 Java 元素 1 切换到 Flex 视图 新建 Flexproject 例如以下图说明 Javasourcefo 就是你自己 java 业务源代码存放的根文件夹 在 FB3 里 LCDS 项目旨在将 JavaJ2ee 项目和 FlexLcds 项目混合 当然假设你不选择 combined 两个在一起 那么就麻烦些 要么你再单独新建一个 Flex 项目 而这

    2026年3月26日
    2
  • p99延迟是什么

    p99延迟是什么最近看到一个 p99 不知道代表什么 通过查询得知 p99 9p99p95p90 过去 10 秒内最慢的 x 的请求的平均延迟 其中 X 是数字与 100 的差 例如 p991 403 表示过去的 10 秒内最慢的 1 请求的平均延时为 1 403 秒 p95 过去的 10 秒内最慢的 5 的请求平均延时 转载于 https blog 51cto com

    2026年3月18日
    2
  • linux重命名文件和文件夹的区别_文件夹如何重命名

    linux重命名文件和文件夹的区别_文件夹如何重命名Linux重命名文件和文件夹1.mvlinux下重命名文件或文件夹的命令mv即可以重命名,又可以移动文件或文件夹。例子:将目录A重命名为BmvAB将/a目录移动到/b下,并重命名为cmv/a/b/c例子:ubuntu@ubuntu:~/Public/a2$tree….

    2025年5月28日
    5
  • SerDes接口——架构与电路

    SerDes接口——架构与电路对 Serdes 结构及 8b 10bSerDes 电路进行了简单介绍

    2026年3月19日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号