Graphics refresh problem on PC Androd app simulator

I’m working on a graphical menu using display.newimage to display options.

I load the menu images into a display group

When the user makes a selection, I get rid of the images using group:removeSelf and draw new options based on what the user selects.

Problem:

Sometimes the new images don’t draw even though the code to draw them has run.

The new images do appear if I:

  1. Move the mouse outside the simulation window

  2. Mouse over the “minimize” button at the top of the window after “minimize” tip appears.

This doesn’t seem to be a problem on my Android test devices, just the simulator running on my PC.

I’ve narrowed the problem down to this line of code:

instructionText.text = “Select Launch Point”

I initialize this text field at the top of my main.lua file like this:

local instructionText = display.newText(“Welcome Aboard!”, insX, insY, native.systemFont, 18)

instructionText:setTextColor(0, 0, 0)

If I comment that line out, my game runs fine in the simulator.

I leave it in and my new menu won’t draw unless I move the mouse outside of the simulator window.

A few times with that line in, only the right half of the screen drew!

I use the same line(with slightly different text) in four other functions without any problems.

There is nothing in the output window about warnings or errors

It does not matter where in my function I place this line of code…it always causes a problem.

Ditto with changing the text.

Any help?

Hi @gmplayer,

The “:setTextColor()” API was deprecated when we introduced the current Corona graphics engine around 2 years ago. You should now color/fill text objects (and vector objects) using “:setFillColor()”:

https://docs.coronalabs.com/api/type/ShapeObject/setFillColor.html

Hope this helps,

Brent

Thanks for the tip Brent, but the problem persists even after I upgraded all my text fields.

This almost sounds like a hardware issue, because the Simulator shouldn’t see any significant behavior depending where you “mouse over” the Corona Simulator window. Have you updated your graphics card drivers to the latest version? What are you system specs in general?

Thanks,

Brent

Dell XPS 8300. Intel Core i7 - 2600 CPU @ 3.4 GHz, 16 gigs of RAM, AMD Radeon HD 6800 running windows 7

Do you have any similar issues when you run the basic Corona “Hello World” sample project? It’s located in your local Corona application folder here:

CoronaSDK-XXXX > SampleCode > GettingStarted > HelloWorld

Brent

Brent,

Hello World works fine.

As does my program if I comment out that one text statement.

Remind me again, which one specific line is causing the issue?

instructionText.text = “Select Launch Point”

I ran my app longer on my Android device and found it does develop a different but just as weird problem later in the code, which leads me to believe I have some kind of memory leak problem which is stomping on the code.

It just happens sooner in the simulator than on my Android device.

I found a nice tutorial on how to track down memory leak problems.

I’ll give it a try a report back.

Thanks for your help.

My memory seems to be leak free!

These lines of code appear to be causing the problem:

– Remove Grid Lines

Grid:removeSelf()

Grid = nil

Grid = display.newGroup()

My app has a grid that I draw at the start of each round.

I load the lines into a display group and at the end of each round I clear them using the above code.

I create a new display group for use in the next round in the third line.

I get no errors or warning in the output window.

If I separate the creation of the new display group from the removal of the old group by a few lines, it doesn’t cause problems.

Is there a way to flush everything in a display group without destroying it?

Hi @gmplayer,

Yes, you can remove group children with a simple “backwards” loop like this:

[lua]

for i = Grid.numChildren,1,-1 do

    local child = Grid[i]

    display.remove( child )

    child = nil

end 

[/lua]

Brent

Thanks Brent,

That makes my life easier.

The problem seems to “fixed” just by reversing the order that I create my display groups.

The display group that would only display when I moved my mouse outside the simulator window displays fine now.

From this:

Grid = display.newGroup()

directions = display.newGroup()

To this:

directions = display.newGroup()

Grid = display.newGroup()

Weird.

I’ve added another graphic to my menu and the problem has returned.

One thing I’ve noticed: The very first time I run my app and encounter the problem, I get the spinny mouse cursor that indicates windows is waiting for something…and then the program draws normally.

Just once, though.

The next time I encounter the bug, I have to move my mouse outside the simulator screen to get it to show what it has drawn.

I’ve narrowed the problem down to this line of code:

instructionText.text = “Select Launch Point”

I initialize this text field at the top of my main.lua file like this:

local instructionText = display.newText(“Welcome Aboard!”, insX, insY, native.systemFont, 18)

instructionText:setTextColor(0, 0, 0)

If I comment that line out, my game runs fine in the simulator.

I leave it in and my new menu won’t draw unless I move the mouse outside of the simulator window.

A few times with that line in, only the right half of the screen drew!

I use the same line(with slightly different text) in four other functions without any problems.

There is nothing in the output window about warnings or errors

It does not matter where in my function I place this line of code…it always causes a problem.

Ditto with changing the text.

Any help?

Hi @gmplayer,

The “:setTextColor()” API was deprecated when we introduced the current Corona graphics engine around 2 years ago. You should now color/fill text objects (and vector objects) using “:setFillColor()”:

https://docs.coronalabs.com/api/type/ShapeObject/setFillColor.html

Hope this helps,

Brent

Thanks for the tip Brent, but the problem persists even after I upgraded all my text fields.

This almost sounds like a hardware issue, because the Simulator shouldn’t see any significant behavior depending where you “mouse over” the Corona Simulator window. Have you updated your graphics card drivers to the latest version? What are you system specs in general?

Thanks,

Brent

Dell XPS 8300. Intel Core i7 - 2600 CPU @ 3.4 GHz, 16 gigs of RAM, AMD Radeon HD 6800 running windows 7

Do you have any similar issues when you run the basic Corona “Hello World” sample project? It’s located in your local Corona application folder here:

CoronaSDK-XXXX > SampleCode > GettingStarted > HelloWorld

Brent