Corona SDK 中的 Sprite 位置

发布于 2024-11-26 01:15:35 字数 544 浏览 1 评论 0 原文

我不明白 Corona SDK 中的一些对象位置概念

,我创建了精灵表:

local spriteSheet = sprite.newSpriteSheet("button.png", 138, 64);
local spriteSet = sprite.newSpriteSet(spriteSheet, 1, 2);
local sp = sprite.newSprite( spriteSet );

精灵也超出了屏幕范围

它的位置很奇怪,即使我将 x 和 y 位置设置为零config.lua,

application =
{
    content =
    {
        width = 320,
        height = 480,
        scale = "letterbox"
    },
}

:我认为问题在“ ReferencePoint”

只是告诉我如何更改默认屏幕的 setReferencePoint(不是图像或组...),只是默认屏幕...

I didn't understand some object position concepts in Corona SDK

I have created sprite sheet:

local spriteSheet = sprite.newSpriteSheet("button.png", 138, 64);
local spriteSet = sprite.newSpriteSet(spriteSheet, 1, 2);
local sp = sprite.newSprite( spriteSet );

and it's positions are strange and sprite is out of screen bounds even I set x and y positions to zero

config.lua is:

application =
{
    content =
    {
        width = 320,
        height = 480,
        scale = "letterbox"
    },
}

I think that problem in "referencePoint"

just say me how to change setReferencePoint of default screen (not image or group ...), just default screen...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清旖 2024-12-03 01:15:35

从技术上讲,您可以通过创建显示组并将所有内容附加到该组来为所有图形使用不同的坐标系,但实际上您似乎问了错误的问题。您应该想知道为什么精灵位置不正确,而不是尝试更改屏幕的参考点。

请创建一个新问题,重点关注该问题并进一步解释它,因为您在这里所说的只是这些立场“奇怪”。那是什么意思?

Technically you can use a different coordinate system for all your graphics by creating a display group and attach everything to that group, but really it seems like you're asking the wrong question. Rather than trying to change the reference point of the screen, you should be wondering why your sprites aren't positioned correctly.

Please create a new question that focuses on that problem and explains it further, because all you say here is that the positions are "strange". What's that mean?

笑忘罢 2024-12-03 01:15:35

您可以像下面这样修改代码并检查它,它会起作用:

local spriteSheet = sprite.newSpriteSheetFromData( "button.png",require("button").getSpriteSheetData())
local spriteSet = sprite.newSpriteSet(spriteSheet,1,9);
sprite.add(spriteset,"button",1,9,1000,0);
//button is lua file use button.lua
local sp = sprite.newSprite( spriteSet );
sp:prepare("button");
sp.x = display.screenOriginX+138;
sp.y =  display.screenOriginY+64; 

You can modify your code like below and just check it,it will work:

local spriteSheet = sprite.newSpriteSheetFromData( "button.png",require("button").getSpriteSheetData())
local spriteSet = sprite.newSpriteSet(spriteSheet,1,9);
sprite.add(spriteset,"button",1,9,1000,0);
//button is lua file use button.lua
local sp = sprite.newSprite( spriteSet );
sp:prepare("button");
sp.x = display.screenOriginX+138;
sp.y =  display.screenOriginY+64; 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文