Skip to content

Commit

Permalink
added new slider - colorModification, fixed issue with boolean sliders
Browse files Browse the repository at this point in the history
  • Loading branch information
krystian committed Mar 19, 2012
1 parent 17f9c2f commit ea86871
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
3 changes: 2 additions & 1 deletion configuration.lua
Expand Up @@ -42,11 +42,12 @@ DefaultProperties.scaleInSpeed=0
DefaultProperties.scaleMax=1
DefaultProperties.scaleOutDelay=0
DefaultProperties.scaleOutSpeed=0
DefaultProperties.colorModification=0
DefaultProperties.colorStartR=0
DefaultProperties.colorStartG=0
DefaultProperties.colorStartB=0
DefaultProperties.colorChangeR=0
DefaultProperties.colorChangeG=0
DefaultProperties.colorChangeB=0
DefaultProperties.emissionRate=5
DefaultProperties.emissionAngle=90
DefaultProperties.emissionAngle=90
19 changes: 10 additions & 9 deletions main.lua
Expand Up @@ -58,14 +58,15 @@ Properties[19] = { name = "scaleInSpeed", min = 0, max = 2, default = DefaultPr
Properties[20] = { name = "scaleMax", min = 0, max = 10, default = DefaultProperties.scaleMax, isInteger = false}
Properties[21] = { name = "scaleOutDelay", min = 0, max = 5000, default = DefaultProperties.scaleOutDelay, isInteger = true}
Properties[22] = { name = "scaleOutSpeed", min = -1, max = 0, default = DefaultProperties.scaleOutSpeed, isInteger = false}
Properties[23] = { name = "colorStartR", min = 0, max = 255, default = DefaultProperties.colorStartR, isInteger = true}
Properties[24] = { name = "colorStartG", min = 0, max = 255, default = DefaultProperties.colorStartG, isInteger = true}
Properties[25] = { name = "colorStartB", min = 0, max = 255, default = DefaultProperties.colorStartB, isInteger = true}
Properties[26] = { name = "colorChangeR", min = -255, max = 255, default = DefaultProperties.colorChangeR, isInteger = true}
Properties[27] = { name = "colorChangeG", min = -255, max = 255, default = DefaultProperties.colorChangeG, isInteger = true}
Properties[28] = { name = "colorChangeB", min = -255, max = 255, default = DefaultProperties.colorChangeB, isInteger = true }
Properties[29] = { name = "emissionRate", min = 1, max = 30, default = DefaultProperties.emissionRate, isInteger = true }
Properties[30] = { name = "emissionAngle", min = 0, max = 359, default = DefaultProperties.emissionAngle, isInteger = true }
Properties[23] = { name = "colorModification", min = 0, max = 1, default = DefaultProperties.colorModification, isBoolean = true}
Properties[24] = { name = "colorStartR", min = 0, max = 255, default = DefaultProperties.colorStartR, isInteger = true}
Properties[25] = { name = "colorStartG", min = 0, max = 255, default = DefaultProperties.colorStartG, isInteger = true}
Properties[26] = { name = "colorStartB", min = 0, max = 255, default = DefaultProperties.colorStartB, isInteger = true}
Properties[27] = { name = "colorChangeR", min = -255, max = 255, default = DefaultProperties.colorChangeR, isInteger = true}
Properties[28] = { name = "colorChangeG", min = -255, max = 255, default = DefaultProperties.colorChangeG, isInteger = true}
Properties[29] = { name = "colorChangeB", min = -255, max = 255, default = DefaultProperties.colorChangeB, isInteger = true }
Properties[30] = { name = "emissionRate", min = 1, max = 30, default = DefaultProperties.emissionRate, isInteger = true }
Properties[31] = { name = "emissionAngle", min = 0, max = 359, default = DefaultProperties.emissionAngle, isInteger = true }

Sliders = {}

Expand All @@ -82,4 +83,4 @@ local tabBar = widget.newTabBar{
buttons = tabButtons
}

onFirstView() -- invoke first tab button's onPress event manually
onFirstView() -- invoke first tab button's onPress event manually
2 changes: 1 addition & 1 deletion settingsTab.lua
Expand Up @@ -91,7 +91,7 @@ function scene:createScene(event)
mySlider.x = sliderX
mySlider.y = sliderY

sliderY = sliderY + 31
sliderY = sliderY + 30

group:insert(nameLbl)
group:insert(valueLbl)
Expand Down
6 changes: 2 additions & 4 deletions slider.lua
Expand Up @@ -80,15 +80,13 @@ local function newSliderHandler( self, event )
end

if (self.isInteger) then
if (self.isBoolean) then
sliderEvent.value = math.floor(self.value)
elseif (self.isBoolean) then
if (self.value == 0) then
sliderEvent.value = false
else
sliderEvent.value = true
end
else
sliderEvent.value = math.floor(self.value)
end
else
sliderEvent.value = tonumber(string.format("%.3f", self.value))
end
Expand Down
13 changes: 7 additions & 6 deletions testTab.lua
Expand Up @@ -36,7 +36,7 @@ function scene:enterScene( event )

bg:setFillColor( BackgroundColor[1], BackgroundColor[2], BackgroundColor[3] )

Particles.CreateEmitter("E1", 384, 512, Sliders[30].slider:getValue(), true, true)
Particles.CreateEmitter("E1", 384, 512, Sliders[31].slider:getValue(), true, true)


group:insert(Particles.GetEmitter("E1"))
Expand Down Expand Up @@ -66,9 +66,10 @@ function scene:enterScene( event )
ParticleProps.scaleMax = Sliders[20].slider:getValue()
ParticleProps.scaleOutDelay = Sliders[21].slider:getValue()
ParticleProps.scaleOutSpeed = Sliders[22].slider:getValue()
ParticleProps.colorStart = {Sliders[23].slider:getValue(),Sliders[24].slider:getValue(),Sliders[25].slider:getValue()}
ParticleProps.colorChange = {Sliders[26].slider:getValue(),Sliders[27].slider:getValue(),Sliders[28].slider:getValue()}

if (Sliders[23].slider:getValue()) then
ParticleProps.colorStart = {Sliders[24].slider:getValue(),Sliders[25].slider:getValue(),Sliders[26].slider:getValue()}
ParticleProps.colorChange = {Sliders[27].slider:getValue(),Sliders[28].slider:getValue(),Sliders[29].slider:getValue()}
end
ParticleProps.imagePath = ParticleImage.name
ParticleProps.imageWidth = ParticleImage.width
ParticleProps.imageHeight = ParticleImage.height
Expand All @@ -79,7 +80,7 @@ function scene:enterScene( event )
Particles.CreateParticleType (name, ParticleProps)

-- FEED EMITTERS (EMITTER NAME, PARTICLE TYPE NAME, EMISSION RATE, DURATION, DELAY)
Particles.AttachParticleType("E1", name, Sliders[29].slider:getValue(), 99999,0)
Particles.AttachParticleType("E1", name, Sliders[30].slider:getValue(), 99999,0)



Expand Down Expand Up @@ -130,4 +131,4 @@ scene:addEventListener( "destroyScene", scene )

-----------------------------------------------------------------------------------------

return scene
return scene

0 comments on commit ea86871

Please sign in to comment.