mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
25 lines
545 B
Lua
25 lines
545 B
Lua
local class = require "class"
|
|
|
|
local Car, CarBase = class("Car")
|
|
|
|
function Car:__init(x, y)
|
|
self.x = x or 0
|
|
self.y = y or 0
|
|
end
|
|
|
|
function CarBase:print() -- this will be correct
|
|
print("I'm a car, at ("..self.x..","..self.y..")")
|
|
end
|
|
|
|
local Motorcycle, MotorcycleBase = class("Motorcycle", Car)
|
|
|
|
function Motorcycle:__init(x, y)
|
|
Car.__init(self, x, y) -- if you want to use a parent's constructor, you must manually call it
|
|
|
|
-- do additional stuff or whatever
|
|
end
|
|
|
|
function MotorcycleBase:someFunc()
|
|
-- do whatever to an instance
|
|
end
|