how to make text scaling
krumza

Hello again! I have a problem with the text sprite; In the project there are several types of objects - points, lines, pointer. This sets of sprites: image + text sprite. To make the text not overlap with the image it moves in a circle around the object, as if "running away" from it;

cursor.getSprite(1).setText(truncated(PxToCm(Math.sqrt(DX*DX+DY*DY)),0)+" см");
cursor.setSpriteOffset(1,{x:-80*DY/Math.sqrt(DX*DX+DY*DY),y:80*DX/Math.sqrt(DX*DX+DY*DY)});

However, I do have the ability to scale from scrolling and it is clear that the entire text is also reduced.

Well, so far, translated into English seems to have found a solution

wade.app.onCameraMove = function(data){
   tape_measure_text.setFont(20*data.newPosition.z+'px lato');
};

There are still ways to solve this?

All 4 Comments
Gio

Just to be sure that I understand what you want to achieve, do you want your text to be a fixed size on the screen regardless of camera zoom?

If so, could you put it into a separate layer with zero scale and translate factors? Then you wouldn't need to change the font size

krumza

To make the text not overlap with the image it moves in a circle around the object, as if "running away" from it;

If i change layer for textsprite - i am deep to algebra hell as i think

Gio

It is probably much easier than you think.

Let's say that you have your  lines and squares on layer 5, and that has got a normal layer transform {scale: 1, translate: 1}

Then you put your text on layer 4, with {scale: 0, translate: 0}. Basically this means that layer 4 coordinates are exactly the same as screen coordinates.

To get your text object coordinates in layer 5's space you would just do:

var pos = myTextObject.getPosition(); // position in layer 4's coordinate space
pos = wade.screenPositionToWorld(5, pos); // position in layer 5's coordinate space

That looks like a really cool app by the way

krumza

thanks, Gio!  that's very flattering to read this!

 

Post a reply
Add Attachment
Submit Reply
Login to Reply