Created
May 7, 2013 01:36
-
-
Save maykelsb/5529672 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1) | |
function enemy:shoot() | |
local Bullet = require "Bullet"; | |
Bullet.owner = self; | |
-- the same as your previous code | |
end; | |
function enemy:canShootAgain() | |
self.activeBul = false; | |
end; | |
-- When you want the enemy to shoot again, just call canShootAgain from bullet | |
bullet.owner:canShootAgain(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 2) | |
function enemy:shoot() | |
local Bullet = require "Bullet"; | |
Bullet.owner = self; | |
-- the same as your previous code | |
end; | |
function enemy:canShootAgain() | |
self.activeBul = false; | |
end; | |
-- When you want the enemy to shoot again, just call canShootAgain from bullet | |
bullet.owner:dispatchEvent({name = 'canShootAgain'}); | |
-- Add this to the end of your enemy construction | |
enemy:addEventListener('canShootAgain', enemy); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/questions/16391401/bullet-fire-reset-event-corona-sdk/16401418#16401418