A million free points (which are totally worthless except for bragging rights) to the first person who can correct my absolutely abysmal, gross incompetence.
Why does the first print(self.x) work, but the second returns nil?
This is the main tab:
-- temp3
-- Use this function to perform your initial setup
function setup()
print("Hello World!")
buggy = Bug(777)
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
-- This sets the line thickness
strokeWidth(5)
--buggy:draw()
-- Do your drawing here
end
This is the bug tab:
Bug = class()
function Bug:init(x)
-- you can accept and set parameters here
self.x = x
print(self.x)
self.InitImages()
end
function Bug:InitImages()
print(self.x)
end
function Bug:draw()
-- Codea does not automatically call this method
print(self.x)
end
function Bug:touched(touch)
-- Codea does not automatically call this method
end