easeljs中text控件示例
来源:互联网 发布:德卡斯特里奥算法 编辑:程序博客网 时间:2024/05/20 10:54
先编写html文件,引入相应的easeljs文件,添加canvas标签
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>easelJs的text控件</title> <script src="easeljs-0.8.1.min.js"></script> <style> #gameView{ background-color: #0088bb; } </style></head><body><canvas id="gameView" width="500px" height="400px"></canvas><script src="text.js"></script></body></html>再编写js代码
var canvas,stage,text,rect;var count=0;canvas=document.getElementById("gameView");//创建stagestage=new createjs.Stage(canvas);//创建text对象text=new createjs.Text("text on the canvas...0!","36px Arial","#fff");text.x=50;text.y=50;text.rotation=20;stage.addChild(text);//创建矩形对象rect=new createjs.Shape();rect.x=text.x;rect.y=text.y;rect.rotation=text.rotation;stage.addChildAt(rect,0);createjs.Ticker.setFPS(20);createjs.Ticker.addEventListener("tick",handlerTick);function handlerTick(e){ count++; text.text="text on the canvas..."+count+"!"; rect.graphics.clear().beginFill("#f00").drawRect(-10,-10,text.getMeasuredWidth()+20,50); stage.update(e);}
最后效果如图:
0 0
- easeljs中text控件示例
- easeljs中的movieClip控件示例
- select控件获取text值示例代码
- EaselJS的Text中文不会自动换行的问题
- matlab中 text 使用画图示例
- text控件监听键盘弹出和关闭示例代码
- EaselJS 简介
- EaselJS 事件
- C#中控件的命名规范示例
- Apache Commons Text示例
- RequiredFieldValidator控件中Text属性和ErrorMessage属性用法
- 在MFC中使用Static text控件显示消息
- 获取页面中所有类型为text的input控件
- VB中Text控件获得焦点的同时全选
- VB中如何让text控件设置成透明
- 在Static Text控件中显示JPG图片
- Android中自定义控件获取text的宽高方式
- MFC中设置Edit Control 和 Static Text控件学习
- spring学习笔记(7)——spring事务管理方式
- 启动oracle服务和监听的批处理
- 1.hibernate入门
- Html5无刷新修改Url,history pushState/replaceState
- C/C++中static关键字详解
- easeljs中text控件示例
- 深入探讨 java.lang.ref 包
- Android下资源使用的方式-android学习之旅(五十三)
- cocos2d-x3.6 连连看触摸事件传递
- 尼康镜头D 和G的区别
- Ace of Aces
- 欢迎使用CSDN-markdown编辑器
- activity以绑定服务的方式开启服务并调用服务里面的方法
- dom4j解析节点名称和值