Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.x/y/z are back. #18228

Merged
merged 1 commit into from
Jan 22, 2025
Merged

Node.x/y/z are back. #18228

merged 1 commit into from
Jan 22, 2025

Conversation

dumganhar
Copy link
Contributor

It will be easier for just set one axis value. For example, while using Tween animation, we want to make a sprite jump up and down forever and move x to 100, it will be hard to achieve that if Node.x/y/z are absent.

Example:

import { _decorator, Component, Node, tween } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('xyz')
export class xyz extends Component {
    start() {

        tween(this.node)
            .delay(10)
            .parallel(
                tween().by(4, { x: 300 }),
                tween()
                    .by(0.2, { y: 50 })
                    .by(0.2, { y: -50 })
                    .union()
                    .repeat(1000),
            )
            .start();
    }
}
xyz.mp4

Re: https://forum.cocos.org/t/topic/158404/28?u=dumganhar

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

It will be easier for just set one axis value. For example, while using Tween animation, we want to make a sprite jump up and down forever and move x to 100, it will be hard to do that if Node.x/y/z are absent.
@dumganhar dumganhar requested a review from minggo January 21, 2025 10:51
Copy link

⚠️ Package size ⤴ 783 bytes, old: 5229443, new: 5230226

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -24689,14 +24689,74 @@
          */
         get position(): Readonly<math.Vec3>;
         set position(val: Readonly<math.Vec3>);
         /**
+         * @en Get x axis value in local coordinate system
+         * @zh 获取本地 x 轴坐标分量
+         */
+        get x(): number;
+        /**
+         * @en Set x axis value in local coordinate system
+         * @zh 设置本地 x 轴坐标分量
+         */
+        set x(val: number);
+        /**
+         * @en Get y axis value in local coordinate system
+         * @zh 获取本地 y 轴坐标分量
+         */
+        get y(): number;
+        /**
+         * @en Set y axis value in local coordinate system
+         * @zh 设置本地 y 轴坐标分量
+         */
+        set y(val: number);
+        /**
+         * @en Get z axis value in local coordinate system
+         * @zh 获取本地 z 轴坐标分量
+         */
+        get z(): number;
+        /**
+         * @en Set z axis value in local coordinate system
+         * @zh 设置本地 z 轴坐标分量
+         */
+        set z(val: number);
+        /**
          * @en Position in world coordinate system
          * @zh 世界坐标系下的坐标
          */
         get worldPosition(): Readonly<math.Vec3>;
         set worldPosition(val: Readonly<math.Vec3>);
         /**
+         * @en Get x axis value in world coordinate system
+         * @zh 获取世界坐标 x 轴分量
+         */
+        get worldPositionX(): number;
+        /**
+         * @en Set x axis value in world coordinate system
+         * @zh 设置世界坐标 x 轴分量
+         */
+        set worldPositionX(val: number);
+        /**
+         * @en Get y axis value in world coordinate system
+         * @zh 获取世界坐标 y 轴分量
+         */
+        get worldPositionY(): number;
+        /**
+         * @en Set y axis value in world coordinate system
+         * @zh 设置世界坐标 y 轴分量
+         */
+        set worldPositionY(val: number);
+        /**
+         * @en Get z axis value in world coordinate system
+         * @zh 获取世界坐标 z 轴分量
+         */
+        get worldPositionZ(): number;
+        /**
+         * @en Set z axis value in world coordinate system
+         * @zh 设置世界坐标 z 轴分量
+         */
+        set worldPositionZ(val: number);
+        /**
          * @en Rotation in local coordinate system, represented by a quaternion
          * @zh 本地坐标系下的旋转,用四元数表示
          */
         get rotation(): Readonly<math.Quat>;

@minggo minggo merged commit 9b4dfdb into cocos:v3.8.6 Jan 22, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants