How to draw a filled square behind text in libgdx? - libgdx

I am developing a grid based game in libgdx. What i want is to know how can i draw a square tile with number written on it which can be moved and scaled.
Its stupidity to design thousands of textures for these numbers and use them as sprites.I want to know if there is any container class in which i can dynamically add text and and set background too.

You can use Scene2d UI components such as Label to create styled text boxes.
Scene2d allows you to do layout and styling of a wide range of components that can easily be manipulated using Actions, or you can create your own components by extending Actor.
To create and display a Label, create a Stage and add the Label to it.

In this context I assume you by "tile" just mean a rectangle.
You don't say anything about what you are doing now. How you draw the numbers.
So this answer is based on almost zero information.
Solution 1:
Use a font with a background color.
Solution 2:
You know the number/how many digits. You know the size of the font. Calculate the size of the text on screen. Use a single narrow background sprite and tile it behind the text.
Solution 3:
Use a textbox from Scene2d.

Related

Moving a separate glyph in TextField/TextBlock/TextLine

I want to make an RPG-like animation with text, like waving, shaking, etc. So I need to move separate glyphs in in text container. I looked up in Adobe documentation, but didn't find myself any information about accessing separate glyph graphics, to change it's position/scale/whatever.
Is it possible? Or the only way to do it is to draw glyphs separately from text field to BitmapData and do the whole thing by myself?

How can I create a variable-width stroke in AS3?

Is there any way to create a variable-width stroke on a drawn path? I need to imitate a pen pressure effect (without using a tablet). Can I do this by changing some properties of a stoke?
Thanks in advance
usually dont like just posting links! But this is what you need A Smooth and Responsive Drawing Application in AS3
It determines the thickness by the mouse speed, you can obviously change that to fit your needs

As3 Movieclip background image size

I am working with box2d, and generating a few grounds of variable size (all rectangles). The image the grounds use is 500px by 200px, however, when I create and size my grounds, the background image stretches to fill the body. I am trying to have it aligned to top left and just tile with no resizing but am really unsure of how to control it.
I imported the image as a movieclip to my library, if it helps, and also have a basic empty class for it (EarthGround.as). I've been doing a little research but really haven't found anything definitive about manipulating the movieclips associated image.
You have to be specific with that. Maybe a screen shot would help.
Until then, possible causes could be:
Box2D uses real world values where 1 pixel = 1 meter. You have to
choose a scale factor.
Box2d uses the center of any object as its registration point. You
should always do the same with your flash sprite/movieclip, to keep
it simple.

programmatically create Background Images in Flex 3

I'm developing a visualization for certain parts of a Warehouse with Flex 3. In this visualization there are lot of blocks where 1 to x pallets can be placed where x is between 9 and 15. I need to represent each pallet with a black square, each place which is already assigned to a pallet but not physically taken with a grey square and each free place with a white square. I first thought to just use a canvas for each place on a block and change their color if the state changes. But the hundreds of canvases which are there as a result of this approach are not updated quickly enough for my purposes (screen freezes for a few seconds).
I don't want to use embedded images because of the great amount of images I had to embed in the application (those Images appear in 4 orientations).
My idea was to create background images which reflect the state of the whole block only when needed for that certain state and cache them, so that the computation time is spread over the whole runtime.
My problem now is I don't know how to create them in a way that I can use them as "backgroundImages". As far as I understand I would need them as a class object but I don't know how to achieve that, when not embedding the images.
I'm of course open to better approaches to solve my problem. Thanks for your support.
I would suggest using Graphics property of a Sprite for example. It provides basic drawing API, like drawing lines, circles and rectangles.
Besides, you can draw bitmap images on the Graphics to produce more advances results.

Can we add the Word Art style in flex

Can we add the WORD ART or WARP TEXT style in flex
etc
Just like these images i want to make test like bottom arcs, vertical arcs, Birdseye etc as as shown in the images above.
Please help me is that possible in Flex to make such text fonts styles
you can do an envelope distort
envelope-distort-with-actionscript (download source)
First you will draw your textfield to a bitmap using the myBitmap.draw(myTextField). Then you will use the code below to distort that bitmap.
You can either let the user control it or you could set the handles visible to false and set their x,y to preset positions to achieve different effects.
Are you building a tshirt design tool? I created one of those years ago and had effects like this.
I have found a link where we can obtain the word art style in flash which will be very useful for all click here