Corona sdk question (newbie)
I don't understand how can I add images for order with corona sdk (front, top, middle). I mean like cocos2d I can add example [self addChild:bg z:-1]; [self addChild:nextSprite z:1]; [self addChild:secondSprite z:2]; etc. But there is no z:number value with corona sdk..
All what I have noticed is tha开发者_如何学Pythont when I add newImage it come top with previous newImage..do I have to done that with groups..or what..
I got this problem that when orientation change, background image change as well..but when the image change it hide all buttons..(=come top of screen and hides all other objects under)..
To give a specific answer, I solved this problem by creating initial groups and then adding images to those groups as needed.
local bgGroup = display.newGroup() -- renders first
local midGroup = display.newGroup()
local nearGroup = display.newGroup() -- renders last, over other groups
-- create images/etc
bgGroup:insert(backgroundImage)
midGroup:insert(houseImage)
nearGroup:insert(personImage)
As you found out, Corona does not have explicit z-ordering. Objects are displayed exactly in the order they appear in the group. You can re-insert an object at a particular index if you want to change the order it's drawn, but that's about it.
If you have a specific problem you're having trouble solving, I would recommend you post it as a separate question along with some sample source code. But in general, if you're adding a new image and you want it to go in back of existing images, simply use group:insert specifying an index of 1.
group:insert(1,backimage)
group:insert(2,middleimage)
group:insert(3,fontimage)
hope you got my point.
There are a few ways to solve zindex's in Corona SDK
1) The method you suggested where everything is in separate groups.
2) group:insert([int],displayObject) where [int] is the position you want the display object to render in the group. So 1 is on the bottom, 2 would be in the middle, and 3 would be on top.
3) You can use functions like displayObject:toFront() or displayObject:toBack() to re-position display objects. You can also re-insert the object into the same group to add it to the top, or even a new position (see method 2).
i would check out Object.alpha = 0.8 (or whatever number you choose below 1.0) basically you can make it appear in front of other objects it works fairly well.
精彩评论