What is the object.isShowing?

Hi, I have found this code from the Techniques for Swapping Images tutorial.

local imageGroup = display.newGroup()

local imageCache = {

"red-ball.png" ,

"blue-ball.png" ,

"green-ball.png" ,

"yellow-ball.png" ,

"purple-ball.png"

}

local balls = {}

for i = 1,#imageCache do

balls[i] = display.newImageRect( imageGroup, imageCache[i], 128, 128 )

balls[i].x = display.contentCenterX

balls[i].y = display.contentCenterY

balls[i].isVisible = false

end

imageGroup.isShowing = 1

balls[imageGroup.isShowing].isVisible = true

My one simple question is: what is the .isShowing property in imageGroup? indicated as imageGroup.isShowing. I have not seen this yet in API Reference,
Thank you.

That’s just a custom variable that the developer of that code is using to store the index of what ball should be visible or not.

1 is red. Change it to 3 and the green one should be visible.

1 Like

What Graham said. Under Fill Swap section of Techniques for Swapping Images, you can see an explanation of that variable.

This method eliminates the need for the display group — we just create a base display object (in this case a rectangle the size of the images) and fill it with the image1 paint of red-ball.png. We also declare one additional property for the ball, isShowing

1 Like

Thanks everyone

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