
Share Your Code
Browse Code
- All (911)
-
(94)
-
(86)
-
(44)
-
(4)
-
(42)
-
(137)
-
(22)
-
(41)
-
(13)
-
(65)
-
(152)
-
(211)
Implementing Lightning Effects in Corona
GitHub URL:
https://github.com/astk/Corona-lua-lightning
I've implemented the lightning effect in Corona SDK using Lua and the algorithm as described in the following article.
http://drilian.com/2009/02/25/lightning-bolts/
The result can be seen here:
http://www.youtube.com/watch?v=JnRxfs87ppk
The vector class I used in this file was extended from the following gist:
https://gist.github.com/1006414
Write something like this to create a new lightning. You need to pass the starting and target positions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | local util = require("util") _W = display.contentWidth _H = display.contentHeight gameStates = { menu = 0, pause = 1, gameOver = 2, levelSelection = 3, lightning = 4, inGame = 5}; currentState = gameStates["menu"]; function onTouch(event) if (event.phase == "began") then print("creating lightning...") util.newLightning(_W/2,_H/2,event.x,event.y) _G.currentState = gameStates["lightning"] end end Runtime:addEventListener("touch", onTouch) |
Thanks,
Aung Sithu
http://rivaledge.sg
- Type:
- Tags:
Replies
Posted on Sat, 2011-08-27 04:42
#2
Cool. :D
Cheers!
Posted on Sat, 2011-09-17 00:44
#3
I'm confused how the lightningupdate event knows what startPointX,startPointY, targetX, targetY are as these are not stored.
and each invocation of newLightning will have different values - so it works, but should it?
:-?
Posted on Wed, 2012-04-18 23:55
#4
I really like! Thanks!




nice :) would be good to have a bitmap library in corona to be able to do plasma effects.
my build on your ontouch :)