Problem with text and image

Whats up guys! I’m back.

So I have a little problem. I am creating a mobile 2d game and I ran into problem. I have a “key” image and next to it (in left) a text that shows how many keys you have got.

So my problem is that when your key amount increases, the key text goes increasing step left (more than I want it to go). Here is an image addressing my problem: 

And here is my code used to create both text and the key:

-- create key local key = display.newImage( "assets/key.png", x + w / 10 / 2, y - h / 2.7 ) key.width = w / 4 key.height = h / 15 view:insert( key ) settings.m.key = 4565 local goldScoreText = display.newText ( settings.m.key, x, key.y, font, h / 12 ) goldScoreText:setFillColor( 0, 0, 0 ) goldScoreText.x = x - goldScoreText.width - w / 35 view:insert( goldScoreText )

I hope you can help me with this thing, it is ok if you can’t but still thank you for coming see this post.

I hope you have a good day =)

Best regards

-Coder101

Set ‘anchorX’ on your two objects as follows:

key.anchorX = 0 goldScoreText.anchorX = 1

Next, adjust their positions:

key.x = display.contentCenterX + 10 goldScoreText.anchorX = display.contentCenterX - 10

Adjust from there to suit your preferences.

You don’t need anchors or adjusting positions… just add  width=200, align=“right” to newText.

It’s clearly documented

Set ‘anchorX’ on your two objects as follows:

key.anchorX = 0 goldScoreText.anchorX = 1

Next, adjust their positions:

key.x = display.contentCenterX + 10 goldScoreText.anchorX = display.contentCenterX - 10

Adjust from there to suit your preferences.

You don’t need anchors or adjusting positions… just add  width=200, align=“right” to newText.

It’s clearly documented