Why the skew didnot work

i try to make skew with deepseek the code didnot give me any error but i do not no why the effect didnot work

function myCustomFunction(runtimeScene, parameters) {
// Access parameters
const spriteName = parameters[0]; // First parameter: Sprite name
const skewX = parameters[1]; // Second parameter: Skew X (in radians)
const skewY = parameters[2]; // Third parameter: Skew Y (in radians)

// Debug: Log the parameters
console.log(“Sprite Name:”, spriteName);
console.log(“Skew X:”, skewX, “Skew Y:”, skewY);

// Get the sprite object
const sprites = runtimeScene.getObjects(spriteName);
if (sprites.length === 0) {
console.error(“Sprite not found!”);
return;
}
const sprite = sprites[0];

// Debug: Log the sprite object
console.log(“Sprite found:”, sprite);

// Get the renderer object
const rendererObject = sprite.getRendererObject();
if (!rendererObject) {
console.error(“Renderer object not found!”);
return;
}

// Debug: Log the renderer object
console.log(“Renderer object:”, rendererObject);

// Apply the skew transformation
rendererObject.transform.setFromMatrix(
new PIXI.Matrix(
1, Math.tan(skewY), // a, b
Math.tan(skewX), 1, // c, d
0, 0 // tx, ty (translation)
)
);

console.log(“Skew applied successfully!”);
}

image

When you post Javascript it helps to put it inside preformated text. The option is in the gear icon. This will retain the formatting and it won’t change the quotes. The quotes here are no longer compatible with GD and would need to be changed back to single or double quotes.

I’m not familiar with PIXI and the other elements, so I can’t help beyond this.

Edit: Maybe I’m missing it but you setup a function but I don’t see a call to the function also I don’t see anything getting the parameters.

See this
https://wiki.gdevelop.io/gdevelop5/events/js-code/#use-javascript-to-get-the-value-of-a-parameter-of-a-function

(unmodified version of original post)

Edit #2: I ran the code through a bot to convert the quotation marks back to single quotes. This won’t fix the problem but will allow this code to be tested.

function myCustomFunction(runtimeScene, parameters) {
    // Access parameters
    const spriteName = parameters[0]; // First parameter: Sprite name
    const skewX = parameters[1]; // Second parameter: Skew X (in radians)
    const skewY = parameters[2]; // Third parameter: Skew Y (in radians)

    // Debug: Log the parameters
    console.log('Sprite Name:', spriteName);
    console.log('Skew X:', skewX, 'Skew Y:', skewY);

    // Get the sprite object
    const sprites = runtimeScene.getObjects(spriteName);
    if (sprites.length === 0) {
        console.error('Sprite not found!');
        return;
    }
    const sprite = sprites[0];

    // Debug: Log the sprite object
    console.log('Sprite found:', sprite);

    // Get the renderer object
    const rendererObject = sprite.getRendererObject();
    if (!rendererObject) {
        console.error('Renderer object not found!');
        return;
    }

    // Debug: Log the renderer object
    console.log('Renderer object:', rendererObject);

    // Apply the skew transformation
    rendererObject.transform.setFromMatrix(
        new PIXI.Matrix(
            1, Math.tan(skewY), // a, b
            Math.tan(skewX), 1, // c, d
            0, 0 // tx, ty (translation)
        )
    );

    console.log('Skew applied successfully!');
}
1 Like

I took your code ande this showed to me

It wasn’t my code. It was your code and I labeled it as such.

Because of the way the forum converts quotation marks, your code was converted to the wrong type of quotation marks. I was only trying to help you by displaying your code in an easier to read way. I copied and pasted your code into a preformated text. It still had the wrong style quotes caused by the forum and not by you. That’s probably what caused your last error message. I just had a chatbot change the quotes back to single quotes. I also asked it if it saw any errors and it didn’t.

I still think the issue is there are functions without code to call the function or access the GDevelop parameters. Please see my previous post.

I think you need to get the parameters passed to the function and then call the function using the parameters.