Changing vertexData of a sprite in 2D in cocos creator 3.6.2

Hello all,

I am trying to change the vertices(vertex, index, position, uv) for the sprite in code at runtime. In CC2.4 I was able to change the vertices of the sprite frame by assigning the values to sprite.spriteframe.vertices and setting sprite.setVertsDirty(), but in CC3.6 It doesn’t seem to work even though I updated the format of new vertices.

Any suggestion for best way to achieve this in CC3.6 would be appreciated.

Thank you.

@zhangxm , Do you have any suggestion on this? Atleast some starting point to work on would be great.

Thank you.

I am not sure if it works or not, may be you can get the sprite frame by Sprite.spriteFrame and change its vertex by SpriteFrame.vertices.

Thank you for the response. I just wanted to know what can I use instead of sprite.setVertsDirty in CC33.6. Also whether I need to update all the values like for rawPositions and positions in the vertex data.

New format of spriteframe.vertices -
positions: [],
rawPosition: [],
nuv: [],
uv: [],
indexes: [],
minPos: new Vec3(),
maxPos: new Vec3(),

Also I found out that the sprite in CC3.6.2 does not have the type MESH as in CC2.4. Is there any other way to achieve the same effect?

Hello @zhangxm ,
I was able to modify the vertex data in CC3.6 by converting code from graphics-assembler from CC2.4 but facing one issue depending on the sprite type mesh which is in CC2.4 where there is a function to create render data renderData.createFlexData but I could not find any way to do it in CC3.6.
Since in CC3.6 its creating static data I am not able to render the vertices count when they are changing continuously.(This issue only occurs in android build not in web)

Also the renderData.resize creates new data every time. Any suggestion on this would help.

Thank you!