Rendering of objects of tiny scale.

Suppose you set the xScale and yScale values of an object to something like 0.0001, and its width and height are smaller than the screen, can you be confident that nothing will render? Since it’s an inconvenience not to be able to set scales to 0, this would be a handy work around, but I don’t know how safe it is.

As a workaround, I would suggest calculating the scale and the object’s final width and height first. If either width or height would become zero, just set object.isVisible = false.

Sorry, I should have made myself clearer. I often want to scale things to their final size from nothing and hoped that using a scale of 0.0001 would spare me having to toggle visibility, which for particular reasons in my situation is a tad more complicated than usual. Just a tad, mind, I’m really just being very lazy. Regardless, you’re still suggesting that this is probably a bad idea, so I’ll just have to put in the bit of extra effort.

This is perfectly fine and I do this all the time

That’s good to hear. However, I just tried this:

for i = 1, 500 do 
	local x = display.newRect(i, display.contentCenterY, 50, display.contentHeight)
	x.xScale = 0.00001
	x.rotation = math.random(1,90)
end

… and got a smattering of points in the simulator. Adding an extra zero, though, and there’s no points. This makes me wary, though. With too many zeroes, the whole things gets treated as 0 and nothing is scaled (and there’s a warning in the simulator about setting the xScale to 0). Is it Solar/lua that decides when to round down to 0, or is it something which happens at the hardware level? If the latter case, how does one decide what is a safe value to use?

I use 0.01 when I want to scale from “nothing” and scale up. Works perfectly for my needs.

Do you create things and scale them up right away, or create them with the small scale and leave them hanging about until it’s time for them to scale up? The latter is what I would like to do.

I usually create an object and scale them it away, but if you set yourObject.alpha = 0 when you create it and then set alpha = 1 when you scale it up, that works too. (I’ve found that even at 0.01, you can still see something on the screen, but YRMV.)

If you want to leave them hanging around instead of showing them right away, I’d set the alpha to 0 like other people have said.

I usually show stuff right away so it doesn’t matter to me.

For the objects I re-use, I’ll just set their alpha to 1 or 0 and recycle them as needed.

You can position object out of screen.

Yeah, there’s several alternative options. I guess I’ll just see which is most convenient on a case-by-case basis. Thanks for the input everyone.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.