Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

NewTexture behavior
Started by rune7 Feb 15 2019 12:36 AM

1 reply to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

rune7

[GLOBAL: userInfoPane.html]
rune7
  • Contributor

  • 362 posts
  • Corona SDK

I'm trying to use the newTexture API but getting inconsistent results. The simple code below should produce a horizontal rect 50x20 but I'm getting different sizes and even orientation when displaying the resulted texture on various simulator devices. Why?

local t1 = display.newRect(0,0,50,20)

local tex = graphics.newTexture( { type="canvas", width=t1.contentWidth, height=t1.contentHeight } )
tex:draw(t1)
tex:invalidate()

local t3 = display.newImage(tex.filename, tex.baseDir)
t3.x = 300
t3.y = 300

I need to reliably reproduce a group of objects look when I render them to the texture and then display them in the app.



[TOPIC: post.html]
#2

rune7

[GLOBAL: userInfoPane.html]
rune7
  • Contributor

  • 362 posts
  • Corona SDK

I expected to have an image of the same dimensions as the one drawn to the texture. I'm assuming this is the result of a different device aspect ratio and resolution, but this forces me to keep the original dimensions some where in order to reproduce the same look of the group before rendering. Is there a better way to use this API?




[topic_controls]
[/topic_controls]