【问题标题】:Is there a way to render sprites in Corona SDK/Solar2D in the upper left corner rather than the center?有没有办法在 Corona SDK/Solar2D 中在左上角而不是中心渲染精灵?
【发布时间】:2021-01-17 09:28:36
【问题描述】:

因为我习惯了 pygame 和 Figma,这真的很烦人和困惑。

【问题讨论】:

  • 很确定 Solar2D 使用的是常规坐标点,你能提供你用来定位精灵的代码吗?

标签: lua coronasdk


【解决方案1】:

是的。默认情况下,锚点位于对象的中心。要更改锚点,请使用 anchorXanchorY 属性

local display_object = ...
-- upper left corner
display_object.anchorX = 0
display_object.anchorY = 0

-- down right corner
display_object.anchorX = 1
display_object.anchorY = 1

-- center 
display_object.anchorX = 0.5
display_object.anchorY = 0.5

阅读全文

祝你有美好的一天:)

【讨论】:

  • 有没有办法自动对每个对象执行此操作?无论如何,谢谢。
  • 是的。使用(用于左上角)display.setDefault("anchorX")=0display.setDefault("anchorY")=0 设置默认锚点值。请参阅Display Object Keys 了解更多信息。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-06
  • 1970-01-01
相关资源
最近更新 更多