Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
What's special about gideros.class? — Gideros Forum

What's special about gideros.class?

CarolineCaroline Guru
edited January 2012 in General questions
I am making a Linked List class, and I realised that when I want to do the init function that happens automatically on a gideros.class, I have to call it.

1. What else is special about a gideros.class? (Should I wait for the Gideros Book of All Things?)

2. When using a gideros.class, what is the base class to inherit from - is it EventDispatcher?

3. The linked list class is just a table - I don't think I will need to dispatch events - should I use a gideros.class for it? Is it more efficient not to, and just call list:new() rather than list.new()

Likes: CodeVanya

+1 -1 (+1 / -0 )Share on Facebook

Comments

  • atilimatilim Maintainer
    edited January 2012
    in fact, gideros.class is a simple Lua OO mechanism. Except inheritance, Its implementation is very similar to the code below. You can directly use this instead of inheriting from EventDispatcher:
    LinkedList = {}
    LinkedList.__index = LinkedList
     
    function LinkedList.new(...)
    	local self = setmetatable({}, LinkedList)
    	if self.init ~= nil and type(self.init) == "function" then
    		self:init(...)
    	end	
    	return self
    end
     
    -- your actual LinkedList implementation starts from here
     
    function LinkedList:init()
     
    end
    I may not have answered all of the questions you've asked. Can you ask again if you wonder anything else?
  • In general, it'd be nice to use the gideros class mechanism to create user classes which don't inherit from a gideros class. Some of the other libraries I've seen work even if no argument is passed to the function that creates a class. For example, something like:
    A = gideros.class()
    Would it be possible to add something like that?
  • atilimatilim Maintainer
    I totally agree. We will add this feature.
  • Thank you - Lua is a total dream to work with, compared to Objective C, but there are still some bits that need different thought processes.

  • What is the difference between gideros.class() and Core.class()?

    The Gideros Academy Classes tutorial says to use Core.class()

    Thanks

    Vlado

    Likes: CodeVanya

    +1 -1 (+1 / -0 )Share on Facebook
  • CMIIW Gideros.class is depracated, use Core.class instead

    Likes: CodeVanya

    have fun with our games~
    http://www.nightspade.com
    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.