在Corona SDK中,如何在图像上添加标签(文本)? [英] In Corona SDK how to add label(text) to images?

查看:79
本文介绍了在Corona SDK中,如何在图像上添加标签(文本)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在corona SDK中如何向图像添加标签(文本)

In corona SDK how to add label(text) to images

我已经按照以下步骤创建了图像

I have created my image as follow

    local item = display.newImageRect('images/foo.png',70,70);
    item.x = 50;
    item.y = 50;

如何在图像中添加文字?

How to add a text to the image?

非常感谢

推荐答案

要将文本添加到图像,使其看起来粘在图像上,您可以创建对象(根据需要)以及直接在其上方的文本对象。然后,创建一个组并将它们都粘在其中。

To add text to the image, so it appears to "stick" to the image, you could create the object (as you have) and also the text object directly above it. Then, create a group and stick them both in it.

以下是如何完成此操作的示例:

Here is an example of how that could be done:

local myGroup = display.newGroup()

local item = display.newImageRect('images/foo.png',70,70)
item.x = 50
item.y = 50

local text = display.newText( "My Text", 0, 0, "Helvetica", 18 )
text:setTextColor( 0, 0, 0, 255 )

-- insert items into group, in the order you want them displayed:
myGroup:insert( item )
myGroup:insert( text )

然后,要移动它,只需修改 myGroup的x / y

Then, to move it around, just modify the x/y of 'myGroup'.

希望有帮助!

这篇关于在Corona SDK中,如何在图像上添加标签(文本)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆