Hello everybody! This is the first time i try to modulize my code. I thought i would be easy but its a living nightmare… (just in the begining). Anyhow i can’t get my code to work. It’s splitted up in 3 lua files. Char.lua (My character), Helth.lua(My helth bar and its properties) and main.lua(my main file). Its just the collision thing and the -10 score thing which isnt working.
Hope you guys can help me :)!
Here is my lua files:
[lua]---------My Main.lua----------
display.setStatusBar (display.HiddenStatusBar)
require “physics”
physics.start()
require “Helth”
require “Char”
local W = display.contentWidth
local H = display.contentHeight
local BG = display.newImageRect( “mainBG.png”, 1024, 768 )
BG.x = 512
BG.y = 320
local Ground = display.newImageRect( “ground.png”, 1024, 64 )
Ground.x = 512
Ground.y = 678
Ground.name = “floor”
local Grass = display.newImageRect( “grass.png”, 1024, 128 )
Grass.x = 512
Grass.y = 755
physics.addBody(Grass, “static”)
Char.Char()
Helth.Head()
Helth.Detect()
------------My Char.lua---------------------
module(…, package.seeall)
function Char (event)
local Left = display
local Char = display.newImage (“1.png”)
Char.x = display.contentWidth /2
Char.y = display.contentHeight /2
physics.addBody(Char, “dynamic”)
Char.name = “Char”
end
---------My Helth.lua(all the issues are in this file)–
module(…, package.seeall)
function Char (event)
local Left = display
local Char = display.newImage (“1.png”)
Char.x = display.contentWidth /2
Char.y = display.contentHeight /2
physics.addBody(Char, “dynamic”)
Char.name = “Char”
end
[import]uid: 119384 topic_id: 24863 reply_id: 324863[/import]
I cant find any errors in my code but that beacuse this is the first time im trying to modulize my code (and im pretty new to corona). But mabye you guys can find the issue and help me out :)!