Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

If you have any questions, reports, suggestions, or requests about Live2D, please send them to this community.
※We cannot guarantee statements or answers from Live2D staff. Thank you for your understanding in advance.
Live2D Cubism
Cubism Products and Downloads
Cubism product manuals and tutorials
Cubism Editor Manual    Cubism Editor Tutorial    Cubism SDK Manual    Cubism SDK Tutorial
"[NOTICE]" About the support for Mac models
Cubism Editor is not supported with Apple M1 processors.
Please refer to System Requirements for details.
We will not respond to any related inquiries with this message.
Please note that Cubism SDK is not supported with Apple M1 processors and macOS 11.0 Big Sur.
Live2D user has created a tutorial video(unoffilcial) in English. SEE ALSO.
Thank you, brian_tsui!
[Live2D Tutorial 2020] Introduction to Tools and Technical Concepts

Live2D model position in Cocos2D-X

Hello :)

Im having some issues manipulating the matrix of my Live2D model in cocos2d-x. Let me explain what I want to achieve :
- I want to be able to position my Live2D model using Cocos2D X and Y coordinates.
- I want the model to scale from one screen size to another

For example, when im working in my design resolution (1024*768) I'll specify that my model is drawn at X=350 and Y=768 (that's just an example with random value).
So, I want the render on smaller and bigger resolution to be the same as what I see when Im in 1024*768.

What I have so far :
float scx = (2 / live2DModel->getCanvasWidth());				//Rate of magnification of x axis
float scy = (-2 / live2DModel->getCanvasWidth());				//Rate of magnification of y axis
float x = 0;		//X from 0 to 1024 (design resolution width)
float y = 200;		//Y from 0 to 768 (design resolution height)
float rto = (float)w / h;

float posx = (scx * x);		//Tying to scale X
float posy = (scy * y);		//Trying to scale Y

float matrix[] = {
		scx  , 0  , 0 , 0 ,
		0  , scy , 0  , 0 ,
		0, 0, rto, 0,
		posx, posy, 0, rto

All my game scaling is defined by CC_CONTENT_SCALE_FACTOR(), which is calculated by cocos2d.
How can I achieve the desired behaviour ?
Im not sure I understand correctly why we need to set scx and scy to those value, why do we use 2 and -2 ? shouldn't we use the scale factor ?

Thanks you :)
Sign In or Register to comment.