Hi to everyone,
I’m currently learning corona and lua by setting myself a new game project, the theme of which I’ve decided to be underwater.
Anyway, while searching the forums, I didn’t seem to find any examples of custom effects, so I’m sharing my own discovery to see what people think. You’ll also need the bubble.png texture.
bubble.png (download)
[lua]— bubble wipe transition
local storyboard = require(“storyboard”)
– Load our bubble textures
local bubble_sheet = graphics.newImageSheet(“bubble.png”, {width = 64, height = 64, numFrames = 5, })
– Add a new effect to storyboard (copy of the slideUp transition, with modifications)
storyboard.effectList.bubbles = {
concurrent = true,
to = {
xEnd = 0, xStart = 0,
yEnd = 0, yStart = 384,
– Modified transition
transition = function(t, tMax, start, delta)
local percent = t / tMax
if percent <= 0.5 then
– Add a bubble every tick
local _sprite = display.newSprite(bubble_sheet, {
{name = “float”, start = 1, count = 5, time = 500, loopCount = 0, loopDirection = “bounce”, }
})
_sprite.x = math.random(-63, 543)
_sprite.y = 384
_sprite:play()
– Float the bubble up and destroy it
transition.to(_sprite, {time = math.random(tMax / 2, tMax), y = -64, onComplete = function(obj)
obj:removeSelf()
end, })
end
if percent <= 0.25 then
return start
elseif percent >= 0.75 then
return start + delta
else
– Return normal transitions in a shorter period
return easing.inOutExpo(percent * 2 - 0.5, 1, start, delta)
end
end,
},
from = {
xEnd = 0, xStart = 0,
yEnd = -384, yStart = 0,
transition = function(t, tMax, start, delta)
local percent = t / tMax
if percent <= 0.25 then
return start
elseif percent >= 0.75 then
return start + delta
else
– Return normal transitions in a shorter period
return easing.inOutExpo(percent * 2 - 0.5, 1, start, delta)
end
end,
},
}[/lua] [import]uid: 154787 topic_id: 28368 reply_id: 328368[/import]