Files
CocosCreator-Multi-resoluti…/assets/Script/MultiResolution/CloseToBorderComponent.ts
2019-02-24 20:55:02 +08:00

33 lines
924 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { ccclass, property } = cc._decorator;
/**
* 未完成
*/
@ccclass
export default class CloseToBorderComponent extends cc.Component {
@property({
tooltip: "是否紧贴下方,不能和紧贴上方同时使用"
})
closeToBottom: boolean = false;
@property({
tooltip: "距离下方的距离px开启紧贴下方时使用"
})
marginBottomInPx: number = 0;
// @property({
// tooltip: "是否紧贴上方,不能和紧贴下方同时使用"
// })
// closeToTop: boolean = false;
onLoad() {
// 计算本节点在父节点下,贴底边时的坐标,需要特别注意处理锚点
if (this.closeToBottom) {
this.node.position = cc.v2(
this.node.position.x,
-this.node.parent.height / 2 + this.node.anchorY * this.node.height + this.marginBottomInPx
);
}
}
}