Giter VIP home page Giter VIP logo

dahabit / owl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from booksburrow/owl

0.0 1.0 0.0 116 KB

OWL is a single-module library that provides an easy way to incorporate object-oriented programming concepts into Corona SDK projects. Supports classes that produce display objects (as well as classes that produce non-display objects), and can even be used with non-Corona Lua scripts as well.

Home Page: http://jonbeebe.net

License: MIT License

owl's Introduction

Objects with Lua (OWL)

Easy object-oriented programming in Lua with Corona SDK. Supports display objects, and can also be used with non-Corona Lua scripts.

  • Module: owl.lua
  • Version: 1.0.1
  • License: MIT (see below)
  • Author: Jonathan Beebe
  • Website: http://jonbeebe.net

Features

  • Constructor/initializers via init() method of class (or custom per-instance callbacks)
  • Classes for display objects, as well as non-display objects.
  • Fast creation of new object instances from specified parent class.
  • Create metamethods for objects easily with property callbacks.
  • Familiar OOP methods: is_a(), kind_of(), instance_of()
  • Private class data via .private table of class.
  • Multi-level inheritance (to top-most parent class).

Important Notes

  • Object instances have a reserved property that you cannot read or write to: display_obj
  • Object instances have four read-only properties: class_name, super_class, raw, and callback_properties
  • Classes and instances each have their own private table (e.g. object.private) which does not inherit any data.
  • [Corona SDK] Display object instances have a raw property that can be used to access the display object directly (no inheritance, etc.). This raw property must be used when another function takes a display object as a parameter. For example, to use group:insert(), you would do: group:insert( obj.raw )

Usage

For examples of usage from basic to advanced, see included sample projects. And although OWL.lua can be used with non-Corona SDK Lua scripts, the samples below are Corona SDK projects that should be run in the Corona Simulator. I recommend you study all of the samples (and corresponding Terminal output), and play around with them to gain a more complete understanding of all the features of OWL.

  • Samples/ExternalClasses - shows how to separate classes into external modules.
  • Samples/PrivateClassData - demonstrates how the class and instance 'private' table works.
  • Samples/ClassMethods - shows how to define and use class methods.
  • Samples/EasyMetamethods - shows how to use property callbacks to do creative things.
  • Samples/Constructors - shows how to use class constructors and per-instance constructors.

MIT License

Copyright © 2012 Jonathan Beebe

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

owl's People

Contributors

jonbeebe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.