按钮 按下效果 问题修改

This commit is contained in:
DESKTOP-J7I1C4E\a9350 2024-03-08 20:10:27 +08:00
parent 197028ccc7
commit edba3e9514
5 changed files with 61 additions and 196 deletions

View File

@ -29,7 +29,6 @@ export class BaseSpriteFrame {
tex.updateImage();
this._SpriteFrame.texture = tex;
this._SpriteFrame.offset = v2(Png.Xpos, -Png.Ypos);
console.log(this._SpriteFrame.offset);
this.CallBackFunc(this._SpriteFrame);
this.InitState = true;

View File

@ -1,36 +0,0 @@
import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;
/// 按钮按下效果 在按下时 向下移动一个坐标
@ccclass('ButtonDown')
export class ButtonDown extends Component {
start() {
this.node.on(Node.EventType.TOUCH_START,this.onTouchStart,this);
this.node.on(Node.EventType.TOUCH_END,this.onTouchEnd,this);
this.node.on(Node.EventType.TOUCH_CANCEL,this.onTouchCancel,this);
}
onTouchStart(event:Event){
const pos = this.node.getPosition();
pos.y -= 1;
this.node.setPosition(pos);
}
onTouchEnd(event:Event){
const pos = this.node.getPosition();
pos.y += 1;
this.node.setPosition(pos);
}
onTouchCancel(event:Event){
const pos = this.node.getPosition();
pos.y += 1;
this.node.setPosition(pos);
}
update(deltaTime: number) {
}
}

View File

@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "22f739e6-e4fa-4527-8015-095c71c24f3a",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -27,6 +27,9 @@
],
"_active": true,
"_components": [
{
"__id__": 18
},
{
"__id__": 20
},
@ -38,13 +41,10 @@
},
{
"__id__": 26
},
{
"__id__": 28
}
],
"_prefab": {
"__id__": 30
"__id__": 28
},
"_lpos": {
"__type__": "cc.Vec3",
@ -250,18 +250,15 @@
},
{
"__id__": 15
},
{
"__id__": 17
}
],
"_prefab": {
"__id__": 19
"__id__": 17
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 380,
"y": 258,
"x": 368,
"y": 270,
"z": 0
},
"_lrot": {
@ -380,24 +377,6 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "616ESzd7tK6azbhkiSn+wZ"
},
{
"__type__": "22f73nm5PpFJ4AVCVxxwk86",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 10
},
"_enabled": true,
"__prefab": {
"__id__": 18
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "68tS2o/ulDzLCwmZLhFu2o"
},
{
"__type__": "cc.PrefabInfo",
"root": {
@ -421,7 +400,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 21
"__id__": 19
},
"_contentSize": {
"__type__": "cc.Size",
@ -449,7 +428,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 23
"__id__": 21
},
"_type": 0,
"_inverted": false,
@ -471,7 +450,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 25
"__id__": 23
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@ -517,7 +496,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 27
"__id__": 25
},
"_id": ""
},
@ -535,7 +514,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 29
"__id__": 27
},
"cancel": {
"__id__": 10

View File

@ -23,7 +23,7 @@
"_active": true,
"_components": [],
"_prefab": {
"__id__": 44
"__id__": 42
},
"_lpos": {
"__type__": "cc.Vec3",
@ -54,7 +54,7 @@
},
"autoReleaseAssets": false,
"_globals": {
"__id__": 45
"__id__": 43
},
"_id": "f713b5ea-a70f-486c-8260-0338f089a5b8"
},
@ -76,14 +76,14 @@
],
"_active": true,
"_components": [
{
"__id__": 39
},
{
"__id__": 40
},
{
"__id__": 41
},
{
"__id__": 42
},
{
"__id__": 43
}
],
"_prefab": null,
@ -175,7 +175,7 @@
"_priority": 0,
"_fov": 45,
"_fovAxis": 0,
"_orthoHeight": 345.04285714285714,
"_orthoHeight": 434.12254901960785,
"_near": 0,
"_far": 1000,
"_color": {
@ -526,19 +526,19 @@
"__id__": 25
},
{
"__id__": 31
"__id__": 29
},
{
"__id__": 34
"__id__": 32
}
],
"_active": true,
"_components": [
{
"__id__": 39
"__id__": 37
},
{
"__id__": 40
"__id__": 38
}
],
"_prefab": null,
@ -906,12 +906,6 @@
},
{
"__id__": 28
},
{
"__id__": 29
},
{
"__id__": 30
}
],
"_prefab": null,
@ -942,7 +936,7 @@
"y": 0,
"z": 0
},
"_id": "68JO9KgzZBzaglXLAy5Qu4"
"_id": "67FmNdJkVATpCcbIwgHp2G"
},
{
"__type__": "cc.UITransform",
@ -957,14 +951,14 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 40,
"height": 40
"height": 36
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 1
"x": 0.5,
"y": 0.5
},
"_id": "2cFRkfzuxDZ7IwRpHkN6SQ"
"_id": "a3xOLpvKhNkJRcFhv1C1qQ"
},
{
"__type__": "cc.Sprite",
@ -987,9 +981,9 @@
"a": 255
},
"_spriteFrame": null,
"_type": 1,
"_type": 0,
"_fillType": 0,
"_sizeMode": 2,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
@ -997,10 +991,10 @@
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": false,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": "c2pCm9pjRJJ7j/VPe74xxb"
"_id": "b3Rsdbc51AMpgis1SnRQUd"
},
{
"__type__": "227e93p2mxEV5zjvG1ofJkL",
@ -1017,69 +1011,7 @@
"HoverImgIndex": 2,
"PressImgIndex": 3,
"DisableImgIndex": 4,
"_id": "5fU90+EeRH7b08boyAjpt6"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 25
},
"_enabled": true,
"__prefab": null,
"clickEvents": [],
"_interactable": true,
"_transition": 0,
"_normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_hoverColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_pressedColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_normalSprite": null,
"_hoverSprite": null,
"_pressedSprite": null,
"_disabledSprite": null,
"_duration": 0.1,
"_zoomScale": 1.2,
"_target": null,
"_id": "a5tzyh02NEYJ1QdJN7y0gl"
},
{
"__type__": "22f73nm5PpFJ4AVCVxxwk86",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 25
},
"_enabled": true,
"__prefab": null,
"_id": "d7zWDrkEJBW4iaN5aFUryg"
"_id": "33Uwxk18RJ25Jq8tLo2avm"
},
{
"__type__": "cc.Node",
@ -1093,10 +1025,10 @@
"_active": true,
"_components": [
{
"__id__": 32
"__id__": 30
},
{
"__id__": 33
"__id__": 31
}
],
"_prefab": null,
@ -1135,14 +1067,14 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 31
"__id__": 29
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 14.254856981549944,
"height": 50.4
"width": 14.256042929256663,
"height": 50.400000000000006
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@ -1157,7 +1089,7 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 31
"__id__": 29
},
"_enabled": true,
"__prefab": null,
@ -1174,7 +1106,7 @@
"_string": "∞",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 28.8659793814433,
"_actualFontSize": 22.94283036551078,
"_fontSize": 20,
"_fontFamily": "Arial",
"_lineHeight": 40,
@ -1224,17 +1156,17 @@
"_children": [],
"_active": true,
"_components": [
{
"__id__": 33
},
{
"__id__": 34
},
{
"__id__": 35
},
{
"__id__": 36
},
{
"__id__": 37
},
{
"__id__": 38
}
],
"_prefab": null,
@ -1273,7 +1205,7 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 34
"__id__": 32
},
"_enabled": true,
"__prefab": null,
@ -1295,7 +1227,7 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 34
"__id__": 32
},
"_enabled": true,
"__prefab": null,
@ -1331,7 +1263,7 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 34
"__id__": 32
},
"_enabled": true,
"__prefab": null,
@ -1381,7 +1313,7 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 34
"__id__": 32
},
"_enabled": true,
"__prefab": null,
@ -1425,7 +1357,7 @@
"_enabled": true,
"__prefab": null,
"PressenButton": {
"__id__": 34
"__id__": 32
},
"pressenPrefab": {
"__uuid__": "345ab5d0-8a20-42ec-a630-62a235d82b34",
@ -1512,28 +1444,28 @@
{
"__type__": "cc.SceneGlobals",
"ambient": {
"__id__": 46
"__id__": 44
},
"shadows": {
"__id__": 47
"__id__": 45
},
"_skybox": {
"__id__": 48
"__id__": 46
},
"fog": {
"__id__": 49
"__id__": 47
},
"octree": {
"__id__": 50
"__id__": 48
},
"skin": {
"__id__": 51
"__id__": 49
},
"lightProbeInfo": {
"__id__": 52
"__id__": 50
},
"postSettings": {
"__id__": 53
"__id__": 51
},
"bakedWithStationaryMainLight": false,
"bakedWithHighpLightmap": false