[add] Engine

This commit is contained in:
2022-08-26 16:48:17 +08:00
parent f67e566f2a
commit d9c19f096c
197 changed files with 10626 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
const { ccclass, menu, requireComponent } = cc._decorator;
@ccclass
// @menu("Plug-in/EditBox/EditboxEx")
@requireComponent(cc.EditBox)
export default class EditboxEx extends cc.Component {
//#region private
private _worldPos: cc.Vec2 = null;
//#endregion
//#region Lifecycle
protected onLoad(): void {
if (CC_DEV || cc.sys.isNative) {
let editbox: cc.EditBox = this.node.getComponent(cc.EditBox);
this._worldPos = this.node.GetWorldPosition();
editbox.node.on("editing-did-began", this._onEditDidBegan, this);
editbox.node.on("editing-did-ended", this._onEditDidEnded, this);
}
}
//#endregion
//#region EventListener
private _onEditDidBegan(editbox: cc.EditBox, customEventData: string): void {
let winSizeHeight: number = cc.winSize.height;
let nodeSizeHeight: number = this.node.height / 2;
let targetHeight: number = winSizeHeight - nodeSizeHeight;
let worldPos: cc.Vec2 = cc.v2(this.node.GetWorldPosition().x, targetHeight);
this.node.SetWorldPosition(worldPos);
}
// 假设这个回调是给 editingDidEnded 事件的
private _onEditDidEnded(editbox: cc.EditBox, customEventData: string): void {
this.node.SetWorldPosition(this._worldPos);
}
//#endregion
}

View File

@@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "1e6b0467-4516-4f10-a876-473c8894ff17",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}