Totally weird Result from StageBound!?

I used an approach where my rendering engine works like this:

Using a Group “Board”
Using a Group “Grid”
Using 25 Groups “Cell”
Using a Group “Borders”

The setup works like creating a “Board”

Adding an Rectangle as Background

Greating the “Grid” Group and adding 5 x 5 Cell Groups and setting their x,y to the right offset in the Board (think Checkerboard).

Then it overlays those Grid cells by adding Lines to the “Grid” Group “above” the Cells (which are groups)

The final rendering works like this:

Render all 25 Cells one by one (setting a Rect for Background and put texts inside). This is only done for Cells which need to change.

Render some Borders for grouped cells in the “Borders” group (Boarders are framewise animated, cells change infrequent)

Then inserting the Grid in the Board … then the Border into the Board… Done

All this works…

Here the “Problem”…

The Stage Coordinate are all fucked up if I insert those “Cell” Groups as empty Groups! I need to place something in them before adding them. Which is ok to do but I think a Cell should have a with/height of 0 if nothing is inside.

As it is now I get something like this for the stageBounds

table: 0x3ecac0 {
[xMin] => 11
[xMax] => -2147483648
[yMax] => 3368
[yMin] => 119
}

After all the rendering is looking correctly. I did not even noticed that before trying to translate screen locations to the cell coordinates in the object.

When I add 1 pixel big rect before adding the individual cells into the grid group I get this (expected) result!

table: 0x6e7190 {
[xMin] => 11
[xMax] => 310
[yMax] => 418
[yMin] => 119
}

Btw. I use those individual “Cell” groups to track what to “remove” from the stage when their content changes. I also like the idea of animating them later individually (like shake one when updated)

Does that make sense!?
Did I miss something?
Is it just “wrong” to add groups to groups while they are empty!?
Can I specify the size of a group without rendering something into it?
[import]uid: 6928 topic_id: 1173 reply_id: 301173[/import]

It does seem like an empty group should have a size of zero, or at least not -2147483648. I’ve logged this as bug #260

However, there isn’t a way to specify the size of an empty group, since a group is just a way of attaching display objects together. One possible solution would be to make a small transparent PNG file and resize it to create a “size” for each group, so the group wouldn’t actually be empty. This wouldn’t take much extra texture memory, since you’d just be re-using the same small image in a lot of places. [import]uid: 3007 topic_id: 1173 reply_id: 3286[/import]

I already found a solution by using a vector rect object without the setFillColor().

Actually I don’t understand why I should use a transparent “image” (besides I am coding html :slight_smile:

But to illustrate the bug I mean… try this:

local grp1=display.newGroup()  
  
local sb=grp1.stageBounds  
  
print(sb.xMin, sb.xMax, sb.yMin, sb.yMax)  
  
local rect=display.newRect(0,0,100,100)  
  
grp1:insert(rect)  
  
local sb=grp1.stageBounds  
print(sb.xMin, sb.xMax, sb.yMin, sb.yMax)  
  
local grp2=display.newGroup()  
--grp2.x=100  
  
grp1:insert(grp2)  
  
local sb=grp1.stageBounds  
print(sb.xMin, sb.xMax, sb.yMin, sb.yMax)  

See the line with “–grp2.x=100” … try the example code with and without this line commented out and you will see what I think is the bad thing that happens! [import]uid: 6928 topic_id: 1173 reply_id: 3290[/import]