Problem with progress ring

Hello everyone

I am using the Jason Schroeder progressRing module.

Should I have a hundred circular bars in my scene but I notice that only by creating 10 lined crown problems if I try with a hundred just hangs.

I’d like to know:

  1. why this module is so heavy

  2. there any other kind of solution that I can use

thank you so much

I studied all the code. It’s not hard, I think the main problem is the creation of the mask, believe that use one ready simplifies everything. Furthermore the runtime event could start only if a transaction is required. Right? Only thing I do not understand is why insert mid-slice in a container. I still hope that someone can give me some clarifications.

@jake: sorry the module is not working so great for you. It’s a fairly old piece of code at this point, and there are some known issues that I’d hoped to get around to eventually but haven’t found the time. Most of the issues stem from the “auto masking” which can cause visual irregularities on-device in apps that support multiple screen resolutions because of the very specific requirements Corona places on mask images. One way to get around this is to remove the mask creation code and simply apply your own pre-rendered mask image file. That makes it less flexible as a “one size fits all” solution, but given that you’ll know exactly what size mask you’ll need, it should be fine. It’ll reduce the complexity a great deal, and hopefully make your requirement of having 100 on-screen at once possible (I haven’t tested).

To use your own pre-rendered mask image, just replace the whole “create circular mask for slices” block of code with this (obviously you’ll need to edit the path to your mask image):

local mask = graphics.newMask( "path\_to\_your\_mask\_image" ) bg:setMask(mask) sliceGroup.group:setMask(mask) sliceGroup.group:insert(sliceContainer) group.isCreated = true group:goTo(startPosition, 0, true) group.isVisible = true

The reason for the display container for slices of 180 degrees or less is so that they remain hidden before they rotate into position. I tried various methods to keep slices hidden, but this way worked best in terms of a smooth rotation “from zero.” Of course, you are welcome to modify the code in any way you like, so perhaps you’ll have a better idea. :slight_smile:

Hope this helps!

-Jason

Thank you very much very useful. :slight_smile:

I’ve already made some changes, and predictably the problam derived from the creation of the mask.

I would like to note for people who need that with the changes you reported, the line:

group: goTo (startPosition, 0, true) 

must be inserted after the creation of metedo:

function group.goTo()

also at this point the runtime you can activate only when necessary.

I thank you also for the explanation of the container but still do not understand. :huh:

I tried to put all the slices in the group and still works well…

ok

I did the test and I understand why containers. it’s a good idea. sure it is a second mask so that it leaves only one available but in my case it’s fine.

thanks again and sorry for your time :slight_smile:

saw your support I am pleased to share with you a possible less expensive solution

 local rect local toDo = true local sliceHeight = radius \* 1.5 for i = 0, 350, 10 do local slice = display.newPolygon(0, 0, {0, 0, 0, -sliceHeight, sliceHeight\*.182, -sliceHeight}) local ringColor = {ringColor[1], ringColor[2], ringColor[3]} slice:setFillColor(math.random(), math.random(), math.random()) slice.anchorX, slice.anchorY = 0, 1 slice.target = i if(i \>=180) and (toDo) then rect = display.newRect(0, 0, radius, radius\*2 ) rect:setFillColor(unpack(bgColor)) rect.anchorX = 1 rect.x = 0 sliceGroup.group:insert(rect) toDo = false end sliceGroup.group:insert(slice) slice.rotation = -10 slices[#slices+1] = slice end

and sorry for the different posts in a row

thanks again

I studied all the code. It’s not hard, I think the main problem is the creation of the mask, believe that use one ready simplifies everything. Furthermore the runtime event could start only if a transaction is required. Right? Only thing I do not understand is why insert mid-slice in a container. I still hope that someone can give me some clarifications.

@jake: sorry the module is not working so great for you. It’s a fairly old piece of code at this point, and there are some known issues that I’d hoped to get around to eventually but haven’t found the time. Most of the issues stem from the “auto masking” which can cause visual irregularities on-device in apps that support multiple screen resolutions because of the very specific requirements Corona places on mask images. One way to get around this is to remove the mask creation code and simply apply your own pre-rendered mask image file. That makes it less flexible as a “one size fits all” solution, but given that you’ll know exactly what size mask you’ll need, it should be fine. It’ll reduce the complexity a great deal, and hopefully make your requirement of having 100 on-screen at once possible (I haven’t tested).

To use your own pre-rendered mask image, just replace the whole “create circular mask for slices” block of code with this (obviously you’ll need to edit the path to your mask image):

local mask = graphics.newMask( "path\_to\_your\_mask\_image" ) bg:setMask(mask) sliceGroup.group:setMask(mask) sliceGroup.group:insert(sliceContainer) group.isCreated = true group:goTo(startPosition, 0, true) group.isVisible = true

The reason for the display container for slices of 180 degrees or less is so that they remain hidden before they rotate into position. I tried various methods to keep slices hidden, but this way worked best in terms of a smooth rotation “from zero.” Of course, you are welcome to modify the code in any way you like, so perhaps you’ll have a better idea. :slight_smile:

Hope this helps!

-Jason

Thank you very much very useful. :slight_smile:

I’ve already made some changes, and predictably the problam derived from the creation of the mask.

I would like to note for people who need that with the changes you reported, the line:

group: goTo (startPosition, 0, true) 

must be inserted after the creation of metedo:

function group.goTo()

also at this point the runtime you can activate only when necessary.

I thank you also for the explanation of the container but still do not understand. :huh:

I tried to put all the slices in the group and still works well…

ok

I did the test and I understand why containers. it’s a good idea. sure it is a second mask so that it leaves only one available but in my case it’s fine.

thanks again and sorry for your time :slight_smile:

saw your support I am pleased to share with you a possible less expensive solution

 local rect local toDo = true local sliceHeight = radius \* 1.5 for i = 0, 350, 10 do local slice = display.newPolygon(0, 0, {0, 0, 0, -sliceHeight, sliceHeight\*.182, -sliceHeight}) local ringColor = {ringColor[1], ringColor[2], ringColor[3]} slice:setFillColor(math.random(), math.random(), math.random()) slice.anchorX, slice.anchorY = 0, 1 slice.target = i if(i \>=180) and (toDo) then rect = display.newRect(0, 0, radius, radius\*2 ) rect:setFillColor(unpack(bgColor)) rect.anchorX = 1 rect.x = 0 sliceGroup.group:insert(rect) toDo = false end sliceGroup.group:insert(slice) slice.rotation = -10 slices[#slices+1] = slice end

and sorry for the different posts in a row

thanks again