创建button和key控件时的sound参数可以指定音效名了
This commit is contained in:
@@ -226,10 +226,10 @@ function button:press(_,_,k)
|
|||||||
self.h
|
self.h
|
||||||
)
|
)
|
||||||
if self.sound then
|
if self.sound then
|
||||||
SFX.play('button')
|
SFX.play(self.sound)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font=30][,fType][,sound=true][,align='M'][,edge=0][,code][,hideF][,hide]
|
function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font=30][,fType][,sound][,align='M'][,edge=0][,code][,hideF][,hide]
|
||||||
if not D.h then D.h=D.w end
|
if not D.h then D.h=D.w end
|
||||||
local _={
|
local _={
|
||||||
name= D.name or"_",
|
name= D.name or"_",
|
||||||
@@ -253,11 +253,18 @@ function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font=30][,fType][,
|
|||||||
fType=D.fType,
|
fType=D.fType,
|
||||||
align=D.align or'M',
|
align=D.align or'M',
|
||||||
edge= D.edge or 0,
|
edge= D.edge or 0,
|
||||||
sound=D.sound~=false,
|
|
||||||
code= D.code or NULL,
|
code= D.code or NULL,
|
||||||
hideF=D.hideF,
|
hideF=D.hideF,
|
||||||
hide= D.hide,
|
hide= D.hide,
|
||||||
}
|
}
|
||||||
|
if D.sound==false then
|
||||||
|
_.sound=false
|
||||||
|
elseif type(D.sound)=='string'then
|
||||||
|
_.sound=D.sound
|
||||||
|
else
|
||||||
|
_.sound='button'
|
||||||
|
end
|
||||||
|
|
||||||
for k,v in next,button do _[k]=v end
|
for k,v in next,button do _[k]=v end
|
||||||
setmetatable(_,widgetMetatable)
|
setmetatable(_,widgetMetatable)
|
||||||
return _
|
return _
|
||||||
@@ -347,10 +354,10 @@ end
|
|||||||
function key:press(_,_,k)
|
function key:press(_,_,k)
|
||||||
self.code(k)
|
self.code(k)
|
||||||
if self.sound then
|
if self.sound then
|
||||||
SFX.play('key')
|
SFX.play(self.sound)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,fShade][,color][,font=30][,fType][,sound=true][,align='M'][,edge=0][,code][,hideF][,hide]
|
function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,fShade][,color][,font=30][,fType][,sound][,align='M'][,edge=0][,code][,hideF][,hide]
|
||||||
if not D.h then D.h=D.w end
|
if not D.h then D.h=D.w end
|
||||||
local _={
|
local _={
|
||||||
name= D.name or"_",
|
name= D.name or"_",
|
||||||
@@ -373,13 +380,19 @@ function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,fShade][,color][,font=30][,fT
|
|||||||
color= D.color and(COLOR[D.color]or D.color)or COLOR.Z,
|
color= D.color and(COLOR[D.color]or D.color)or COLOR.Z,
|
||||||
font= D.font or 30,
|
font= D.font or 30,
|
||||||
fType= D.fType,
|
fType= D.fType,
|
||||||
sound= D.sound~=false,
|
|
||||||
align= D.align or'M',
|
align= D.align or'M',
|
||||||
edge= D.edge or 0,
|
edge= D.edge or 0,
|
||||||
code= D.code or NULL,
|
code= D.code or NULL,
|
||||||
hideF= D.hideF,
|
hideF= D.hideF,
|
||||||
hide= D.hide,
|
hide= D.hide,
|
||||||
}
|
}
|
||||||
|
if D.sound==false then
|
||||||
|
_.sound=false
|
||||||
|
elseif type(D.sound)=='string'then
|
||||||
|
_.sound=D.sound
|
||||||
|
else
|
||||||
|
_.sound='key'
|
||||||
|
end
|
||||||
for k,v in next,key do _[k]=v end
|
for k,v in next,key do _[k]=v end
|
||||||
setmetatable(_,widgetMetatable)
|
setmetatable(_,widgetMetatable)
|
||||||
return _
|
return _
|
||||||
|
|||||||
Reference in New Issue
Block a user