It looks like you're new here. If you want to get involved, click one of these buttons!
application:setBackgroundColor(0x323232) foo = Core.class(Sprite) function foo:init(w,h) self.px = Pixel.new(0xff0000, 0.5, w, h) self.px:setAnchorPoint(.5,.5) self:addChild(self.px) end local myholder = Pixel.new(0x0, 0.5, 96, 96) myholder:setPosition(8, 8) myholder:setLayoutParameters({ columnWeights = {1, 1, 1}, rowWeights = {1, 1, 1}, columnWidths = {64, 64, 64}, rowHeights = {64, 64, 64}, }) local mybtn1 = foo.new(4, 4) mybtn1:setLayoutConstraints({ gridx = 1, gridy = 0, gridwidth = 1, gridheight = 1, anchor = Sprite.LAYOUT_ANCHOR_CENTER, fill = Sprite.LAYOUT_FILL_BOTH, }) myholder:addChild(mybtn1) local mybtn2 = Pixel.new(0x00ff00, 0.3, 2, 2) mybtn2:setAnchorPoint(.5,.5) mybtn2:setLayoutConstraints({ gridx = 1, gridy = 1, gridwidth = 1, gridheight = 1, anchor = Sprite.LAYOUT_ANCHOR_CENTER, fill = Sprite.LAYOUT_FILL_BOTH, }) myholder:addChild(mybtn2) local rt = RenderTarget.new(32,32) rt:clear(0x00ffff, 0.3) local mybtn3 = Bitmap.new(rt) mybtn3:setAnchorPoint(.5,.5) mybtn3:setLayoutConstraints({ gridx = 2, gridy = 2, gridwidth = 1, gridheight = 1, anchor = Sprite.LAYOUT_ANCHOR_CENTER, fill = Sprite.LAYOUT_FILL_BOTH, }) myholder:addChild(mybtn3) |
Comments
When I run code, Im getting this:
First, if I remove fill property from "mybtn1", it will appear in top left corner of the "myholder", second, I set anchor to center, so I assume, that my sprite object will be in the center of the cell like this:
But, it's not happening for some reason...
Result of this code
Will be this:
P.S. if someone need this, I can share source code. But, it does not support size change yet.
Likes: MoKaLux, antix
GIF:
Likes: keszegh, hgy29, MoKaLux, Apollo14
I finally got time to try your code and it turns out that yes, layout doesn't work with just Sprite. Builtin layout need to be able to set the size of its content, which is not possible with simple sprites. It works for Pixel and Textfield, but anything else is problematic. I think this is a bug though, since anyhow built in layout should try to make his best to handle Sprite. I will look into it.
Likes: MoKaLux
GIF:
Likes: oleg, MoKaLux
Whilst you are going for the full on "auto layout approach", I'm taking a more traditional "absolute positioning" approach.
Is your solution created entirely in Gideros?
I'm currently using Electron, which gives HTML pages using JavaScript the ability to load and save files on the local hard drive.
A quick example:
Then you can add any item you want using "add" method. It will be inserted right after (below or to the right, depending on your needs) previously added item. Yes
Likes: MoKaLux, antix
Multiple grids of different sizes are created for the screen
Then some elements are tied to a larger grid and others to a smaller grid
When changing screen proportions this way is better.
{type="grid", value=screenW/sizeGrid*numRow+posX},
Likes: MoKaLux
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!