beginner OOP problem with rxi classic

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
drfractal
Prole
Posts: 4
Joined: Sat Jan 18, 2020 3:56 pm

beginner OOP problem with rxi classic

Post by drfractal »

I am studing an OOP approach to develop my löve game so I included this library in my code:

https://github.com/rxi/classic/blob/master/classic.lua

my basic code is like this:

Object = require 'libraries/classic-master/classic'
function love.load()
Stage = Object:extend()

function Stage:new(name)
self.name = name
end
scene = Stage.new("splash")
end

that gives me error in ____ self.name = name ____ line telling me that I am attempting to index global a nil value...
Can someone kindly explain me what is it doing wrong and help me deduce what I have not understood in objects and reference or maybe just in the english sentence of the error message...
Thank you
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: beginner OOP problem with rxi classic

Post by pgimeno »

You need : in the second call:

Code: Select all

scene = Stage:new("splash")
I think this may work as well:

Code: Select all

scene = Stage("splash")
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest