Naming Layers
Posted: Fri Nov 29, 2024 8:18 pm
I don't understand how to name layers.
Could someone please explain, because I find the documentation confusing.
Could someone please explain, because I find the documentation confusing.
The Cross-Platform Multimedia Application Layer
https://forums.hollywood-mal.com/
Code: Select all
EnableLayers()
Circle(10, 10, 30, #RED, {Name="circle1"})
st = GetLayerStyle("circle1")
MoveLayer("circle1", st.x, st.y, st.x+500, st.y+300,{Speed=#SLOWSPEED})
Code: Select all
;ICON-SELECTOR BRUSH:
CreateBrush(2, 70, 70, {Name = "icon_selector"})
ExtendBrush(2, 2, 2, 2, 2, {Color = d_col})
Code: Select all
Function p_ToolsMouseOut()
DebugPrint("Mouse Out!")
RemoveLayer("icon_selector")
EndFunctionCode: Select all
EnableLayers()
SetFillStyle(#FILLCOLOR)
Box(0, 0, 100, 100, #RED) ; create layer 1, which is the last layer created right now
SetLayerName(0, "redbox") ; give the last created layer a name
Box(50, 50, 100, 100, #GREEN) ; create layer 2, which is the last layer created right now
SetLayerName(0, "greenbox") ; give the last created layer a nameIf you look into the documentation of CreateBrush(), you will find no "Name" argument for the table, so it will be ignored. You can assign the name when creating the visible object (the layer) with DisplayBrush().oceanarts wrote: ↑Fri Nov 29, 2024 9:12 pmCode: Select all
CreateBrush(2, 70, 70, {Name = "icon_selector"})
Code: Select all
DisplayBrush(2, #CENTER, #CENTER, {Name="icon_selector"})Code: Select all
Function p_ToolsMouseHover()
DebugPrint("Mouse Hover!")
;DISPLAY ICON-SELECTOR:
DisplayBrush(2, #CENTER, #CENTER + 160)
Local layerid = GetAttribute(#BGPIC, 1, #ATTRLAYERS) ; Bugala Code
SetLayerName(layerid, "icon_selector")
EndFunction
Function p_ToolsMouseOut()
DebugPrint("Mouse Out!")
RemoveLayer("icon_selector")
EndFunctionYou're right, It's better that way. Thanks!Flinx wrote: ↑Tue Dec 03, 2024 5:48 pm GetAttribute() returns the number of layers of this BGPIC, and the last layer (created with DisplayBrush) has this ID. But with my line you could set the name when creating the layer, I think that's a better way.
Code: Select all
;ICON-SELECTOR BRUSH: (REPLACE WITH CUSTOM POLYGON BRUSH(?))
;Brush 2 Created Here:
CreateBrush(2, 70, 70)
ExtendBrush(2, 2, 2, 2, 2, {Color = d_col}
; ***
;FILES-BUTTON FUNCTIONS (attached to a simplebutton):
Function p_FilesMouseOver()
;DISPLAY ICON-SELECTOR:
; Layer containing brush 2 created and named here:
DisplayBrush(2, #CENTER, #CENTER + 160, {name = "icon_selector"})
EndFunction
Function p_FilesMouseOut()
RemoveLayer("icon_selector")
EndFunction