Comments (9)
开始时保存下结束时间new Date().getTime() + 3000;
,然后定时器里判断当前时间和结束时间的对比
可以看这个demo: http://runjs.cn/detail/lvjkgzrw
from hilo.
thanks, the best wishes
from hilo.
@06wj 应用时textAlign和textVAlign不生效
from hilo.
@06wj 看源码知道还需要初始一下宽高就能正常使用textAlign和textVAlign了,这个建议落实到文档提醒下开发者
new Hilo.Text({
font: "bold 43px arial,sans-serif",
textAlign:'right',
textVAlign:'middle',
width: 720,
height: 1080,
text:'30s'
}).addTo(stage);
from hilo.
好 因为canvas本身没这个属性,是通过js根据width,height设置位置实现的,我加到文档里
from hilo.
@jingchaofang http://hiloteam.github.io/Hilo/docs/api-zh/symbols/Text.html#textAlign 已加
from hilo.
建议提供自动计算文字大小的功能。这个并不难。
我之前写的一个 Canvas的Label组件里有类似这样的代码:
if (this._autoSizeWithText && this.textHolder) {
if (this.textHolder.needToCompute) {
this.textHolder.computeSize();
this.computeSizeWithText();
}
}
当没有给Label组件设置大小的时候,则采用『文本内容多大,Label组件就多大』的方案。
宽度用 context.measureText 计算。
高度可以用一个专门计算高度的临时canvas来做,提前计算好。 字体,字号和 高度的映射关系。
(一个游戏里的字体和字号是有限的,不可能想做字处理软件一样无法确定用户到底要用什么字体什么字号)
宽高计算好之后要记得 加上 描边、阴影一类的大小。
from hilo.
自动计算文字大小功能有的,只是textAlign和textVAlign需要手动提供对象的宽高才能实现啊
from hilo.
@06wj , 哦 明白了, 他说的这个 textAlign 是 label 内的 对齐方式, 不是label容器的。我理解错了
from hilo.
Related Issues (20)
- 边框透明度 这个支持吗
- 想做个塔防,怎么做判断攻击范围?
- 【BUG】Hilo.Text创建的文本在IOS/安卓下展示不一致 HOT 1
- ios和安卓中POINTER_MOVE事件stageY坐标不一致问题 HOT 3
- 中心点pivotXY导致文字、绘图偏移
- 竟然没有控制View depth(z-index)的方法。 HOT 1
- 如何让一个bitmap对象,垂直翻转,比如翻翻卡游戏
- 【BUG】Hilo.Tween.to在设置reverse为true的情况下onComplete回调无效 HOT 2
- 如何适配微信小游戏?
- 加载队列error "isTrusted": true
- Camera3d类的sortZ函数中的compareFn返回值问题
- 看来hilo 是阿里私有引擎 连微信小游戏都没适配 HOT 1
- Assertion failed: Moment of Inertia must be positive and non-zero. at assert (physics.js?e0ea:51)
- 求助:怎么换Sprite中Frame,setFrame没用
- canvas模式下Container的属性clipChildren失效
- 有支持dragonbones的mesh动画的计划吗?
- 不打算支持自定义shader吗?
- 停止维护了吗
- 凉了吗?我还想用这个开发个棋牌游戏,现在遇到个View的depth不生效的问题。
- 现在还有人在维护吗,使用standalone,在stage下面使用addChild的话会报错
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hilo.