Comments (6)
可以通过scaleX和scaleY来改变宽高,Hilo里宽高是指原始图形大小
from hilo.
使用ScaleX是可以,但是我无法控制只有一边变小,整个Rect都会在scale中向左边偏移
var countdown = new H.Graphics({alpha : 0.5,scaleX : 1});
countdown.beginFill('#f00');
countdown.drawRect(200,10,400,10);
countdown.endFill();
this.addChild(countdown);
var ticker = new H.Ticker(1);
countdown.tick = function(){
console.log(countdown.x);
countdown.scaleX -= 0.02;
console.log(countdown.scaleX);
}
ticker.addTick(countdown);
ticker.start();
我不知道是因为我的写法不对还是其他原因,求指教,我想做一个进度条逐渐消失的效果,但是矩形会在缩小的同时向左边偏移,即使设置了pivotX和pivotY也没有用,请问实现进度条逐渐消失这个效果还有其他方案么
from hilo.
var countdown = new H.Graphics({alpha : 0.5,scaleX : 1});
countdown.beginFill('#f00');
countdown.drawRect(200,10,400,10);
countdown.endFill();
this.addChild(countdown);
var ticker = new H.Ticker(1);
countdown.tick = function(){
console.log(countdown);
countdown.x += 4;
countdown.scaleX -= 0.02;
console.log(countdown.scaleX);
//使用缩放时,需要移动countdown的X的值 偏差为scaleX * left
}
ticker.addTick(countdown);
ticker.start();
最后用这样的方法解决了,就是略微感觉有点不优雅,不知道为什么width的值是无法设置的,这与我在使用白鹭引擎的时候有很大不同
from hilo.
http://runjs.cn/detail/6qaqyeke
可以x设置200,drawRect时从0开始画
var countdown = new H.Graphics({alpha : 0.5,scaleX : 1,x:200});
countdown.beginFill('#f00');
countdown.drawRect(0,10,400,10);
countdown.endFill();
this.addChild(countdown);
var ticker = new H.Ticker(1);
countdown.tick = function(){
console.log(countdown);
countdown.scaleX -= 0.02;
console.log(countdown.scaleX);
//使用缩放时,需要移动countdown的X的值 偏差为scaleX * left
}
ticker.addTick(countdown);
ticker.start();
或者设置pivotX为200
var countdown = new H.Graphics({alpha : 0.5,scaleX : 1,x:200,pivotX:200});
countdown.beginFill('#f00');
countdown.drawRect(200,10,400,10);
countdown.endFill();
this.addChild(countdown);
var ticker = new H.Ticker(1);
countdown.tick = function(){
console.log(countdown);
countdown.scaleX -= 0.02;
console.log(countdown.scaleX);
//使用缩放时,需要移动countdown的X的值 偏差为scaleX * left
}
ticker.addTick(countdown);
ticker.start();
推荐第一种方案直接把矩形画在x为0处,然后通过x设置200来位移进度条
设置width和设置scaleX是两个有冲突的操作 比如你要显示一张图片原始宽为100的图片,如果你设置width为200其实就是scaleX设置为2了
from hilo.
恩,你的方法更好一些,谢谢了.
另外就是文档只讲述了方法,很多细节以及参数使用需要看源码才能大概了解,但是在用的时候又担心没有遵守规范.建议可以丰富下文档,写一些示范代码,以及最佳实践之类的
from hilo.
感谢建议 我们会完善文档增加教程的 :)
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.