API display.newGroup() Problem [SOLVED]

Hi,

When working with the API [lua]display.newGroup()[/lua] and inserting any display object (I`ve tested using a simple green rectangle) to the group, it has its color changed imediately.

In my example I take a simple absolute green [lua](0, 255, 0)[/lua] rectangle and display it on screen without it being inside any group and so it shows the bright real green on the display as expected. BUT if I insert this same green rectangle inside a localGroup (created using the [lua]display.newGroup()[/lua] API) the color of the real green rectangle changes for another kind of green (a little more as dark-green).

So is it supposed to be like this and I am missing some kind of information that I should know already?

Or is it a real BUG?

PS: If it is a BUG just let me know and I can also submmit it via the link above if necessary.

Thanks,
Rodrigo. [import]uid: 89165 topic_id: 18584 reply_id: 318584[/import]

Hey Rodrigo,

Could you post the exact code and let me know what version of Corona you’re using, please?

Thank you!

Peach :slight_smile: [import]uid: 52491 topic_id: 18584 reply_id: 71370[/import]

Sure Mrs. Peach! :slight_smile:

Following is my code of a Scrolling Background that shows the BUG commented. I`ve used the daily builds number 2011.699 / 2011.700 / 2011.701 respectively

PS: I would like to share this code in the proper forum`s section if it does help others getting the Scrolling Background effect and if I am allowed to do it too. Please, let me know.

[lua]-- Scrolling Background Project Prototype
– Developer: Rodrigo Costa
– Company: RSC Developments®.
– SDK: Corona & Lua
– Date: 04/12/2011
– All rights reserved® to Rodrigo Costa - RSCdev.
– hide the status bar
display.setStatusBar(display.HiddenStatusBar);

– let`s make some constants
local W = display.contentWidth;
local H = display.contentHeight;

– Create a Group
local localGroup = display.newGroup();

– Create a blue sky background
local sky = display.newRect( 0, 0, W, H );
sky:setReferencePoint(display.CenterReferencePoint);
sky:setFillColor(0, 0, 230, 80);
sky.y = H / 2;
sky.x = W / 2;

– Create the scrolling background
local scrollingBkg = display.newRect( 0, 0, 320, 480 )
scrollingBkg:setFillColor(0, 255, 0);
scrollingBkg:setReferencePoint(display.BottomCenterReferencePoint)
–localGroup:insert(scrollingBkg)
– THE BUG START HERE IF YOU DO UNCOMMENT THE LINE ABOVE.
– THE OBJECT WILL HAVE ITS COLOR CHANGED FOR A DARK-GREEN
– WHEN ISERTED TO THE LOCAL GROUP.

local tPrevious = system.getTimer ( )

local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time

–Change this to adjust the speed of the background
local yOffset = (0.03 * tDelta)

scrollingBkg.y = scrollingBkg.y + yOffset

if scrollingBkg.y > 960 then
scrollingBkg:translate(0, -960)
end
end

– Gets the background moving
Runtime:addEventListener(“enterFrame”, move)[/lua]
Cheers,
Rodrigo.

[import]uid: 89165 topic_id: 18584 reply_id: 71377[/import]

Looks like your sky is tinting it when it it’s inserted into the localGroup, because the box is being inserted into the local group, which is behind the sky, and the sky is semi transparent–and thus darkening it slightly.

Move:
local localGroup = display.newGroup();

to after your sky declaration and it all works.

I don’t think it’s a bug, as that is the behavior I’d expect, but someone may know better than me… [import]uid: 19193 topic_id: 18584 reply_id: 71381[/import]

Hi @ScottPhillips ,
Thank you so much for the explanation!!

You got it right away! And so I think also that it isn`t a BUG!!

PS: Peach, MY SORRY for making a topic for something that haven`t any BUG! Apologies. :frowning:

PS2: Ive changed the topics title for [SOLVED] as well for it does not misunderstand anyone.

My bad,
Rodrigo. [import]uid: 89165 topic_id: 18584 reply_id: 71384[/import]