Categories
Corona SDK Lua News Solar2D Technology

Open source rebranding of Corona = Solar2D

 

Open source rebranding of Corona = Solar2D

After using Corona for 10+ years, it is still the easiest and most fun way to make apps and games. With a mature API and friendly programming language Lua, partly thanks to the original creator Walter Luh, Solar2D will continue to shine!

With the MIT license, Solar2D is finally 100% free. Free from splash screen, royalties, building from the server, and company policies. Anyone can also folk the source code and create whatever they want with it.

I’m available for developing apps and games with Solar2D for mobile, tablets, desktop, HTML and Apple TV. Team training will be considered as well.

Categories
Corona SDK Lua Solar2D Technology

Corona SDK -> Solar 2D

The BEST game / app development engine Corona SDK  is rebranded as Solar2D!

Solar2D is fully open source with the MIT license. It is simply the most mature and easy to use 2D game and application development engine available. Developing with Solar2D is much faster than any other SDK because of the simplicity and ease of use of the powerful API and Lua language.

Solar2D – Light Speed Development for Everyone!

Check out Solar2D.com!

Categories
Corona SDK Lua Others

What’s your favorite programming language now?

Having been programming since I was a teenager, I’ve used numerous programming languages on many different platforms over the years: from high-level languages to microcode, from general-purpose languages to task-specific ones, from languages suitable for graphics and multimedia to business and mobile applications.

One privilege of having my own company is I’ve worked on all sorts of projects with both tiny and huge companies, with individuals and large enterprise teams. This experience I gathered over the years has allowed me to understand projects and software development much better than if I were working at the same job and at the same company.

As this tech industry evolves (much quicker than many other industries), I have noticed that things repeat and the pattern is often similar. New technologies (languages, frameworks, tools, etc.) come along and people get excited. Then as these new technologies become more popular, people write books and talk about them in conferences. Soon more people jump on them, and they become bigger and more complicated, and code becomes harder to maintain, leading to more bugs… So, people start to look for something different again – something simpler.

It is interesting to hear one of the most famous game developers talk about his favorite programming language. John Romero, who founded id Software and created influential games that shaped modern-day 3D FPSs, told the audience his favorite programming language (YouTube link).

Incidentally, Lua is also my favorite programming language. It is easy to learn, simple, flexible and fast, no wonder it is used by many top games. The only disadvantage is that not many people realize how powerful Lua is, or they may look down on it because of its simplicity.

And here’s the recommendation that Romero gives for someone who wants to start making games: Use Corona SDK. It is Lua-based, free and open-source. Needless to say, Corona is my tool of choice ever since I first started using it when it became available around 2009.

Categories
Corona SDK Lua News

A new Corona

The day has arrived: Corona Enterprise is now free too!

Now it is just one Corona.

Integrating with native C/C++/Objective-C/Swift/Java code is now available to everyone. I’m sure a lot more developers will be developing native plugins that are sold (or for free) at the Corona Marketplace.

Corona and Lua are the best combination of simplicity, speed, stability, size, deployment choices, and community support for 2D games and app development. (No, I don’t get to paid to say this, I’m just a long-time user / developer.)

https://coronalabs.com/blog/2017/06/21/welcome-to-the-new-corona/

 

Categories
Lua Tutorials

Lua code for OneSignal notification

OneSignal notification example code that are provided here include languages such as Node.js, C#, Python, PHP, Java, Ruby, Perl…, but there’s no Lua.

So here it is, the Lua version for Corona SDK (including a listener):

local json = require "json"

local function listener(e) 
	if e.isError then 
		print("Network Error: ", e.response) 
	else 
		print("Response: ", e.response) 
	end 
end 

local headers = { ["Content-Type"] = "application/json;charset=utf-8", ["Authorization"] = "Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj" } 
local body = { ["app_id"] = "5eb5a37e-b458-11e3-ac11-000c2940e62c", ["included_segments"] = "All", ["data"] = {["foo"] = "bar"}, ["contents"] = {["en"] = "English Message"} } 

network.request("https://onesignal.com/api/v1/notifications", "POST", listener, { headers=headers, body=json.encode(body) })
Categories
Corona SDK Lua Tutorials

UI data binding for Corona SDK

Here is a simple demo of data-binding to user-interface elements in Corona SDK. The purpose is to update variables so that UI elements (textfields in this demo) are updated automatically.

-- UI data binding demo for Corona SDK
--
-- Update variables and UI elements (textfields in this demo) are updated automatically
--
-- Created by:  Dave Yang / Quantumwave Interactive Inc.
-- Version:     1.00

-- place variables inside UIdata
local UIdata = {
    sum = 0,
    rand = -1,
}

-- create the UI elements
local sumTxt = display.newText( UIdata.sum, 150, 125, native.systemFont, 24 )
local randTxt = display.newText( UIdata.rand, 150, 250, native.systemFont, 24 )

-- bind the data to the UI elements
local UIdataBinding = {
    sum = sumTxt,
    rand = randTxt,
}

---------------------------------------------------------------------------

-- reference to the original UIdata table
local _uidata = UIdata

-- empty UIdata to make it work with the metatable below
UIdata = {}

-- the metatable defines what to do with access and change to data in UIdata
local UIdataMT = {
    __index = function(t,k)
        return _uidata[k]
    end,

    __newindex = function(t,k,v)
        -- changes to the data is updated in the textfield; other UI elements can be applied according to type
        UIdataBinding[tostring(k)].text = v
        -- update the original data
        _uidata[k] = v
    end
}

setmetatable(UIdata, UIdataMT)

-- single line if you prefer to replace the lines above starting from 'local UIdataMT = {'
--setmetatable(UIdata, {__index=function(t,k) return _uidata[k] end, __newindex=function(t,k,v) UIdataBinding[tostring(k)].text=v;_uidata[k]=v end})

---------------------------------------------------------------------------

-- change and access data

UIdata.sum = 42
print(UIdata.sum)

UIdata.rand = math.random(99)
print(UIdata.rand)

The latest updates can be found at github.

Categories
Corona SDK Lua OOP Tutorials

Simple demo of implementing Undo and Redo in Corona / Lua

Just posted a simple demo of HistoryStack, to show how Undo and Redo can be implemented in Corona SDK / Lua. It also demonstrates using EventDispatcher to dispatch events to update button states.

https://github.com/daveyang/HistoryStack

 

Categories
Corona SDK Lua News

ZeroBrane Studio updated to 0.90

The excellent ZeroBrane Studio for Lua development has been updated to 0.90, download it here or check out the source code at github.

This open source and free IDE is the best I’ve used for Lua / Corona SDK development. Support from the developer is also quick and excellent. What else can one ask for?

Update: Version 0.95 has been released.
Update: Version 1.00 has been released!

P.S. Check out this blog post for adding Corona SDK show reference.

Categories
Corona SDK Lua OOP

EventDispatcher docs

Documentation has been added for EventDispatcher in LDoc format, generated from the source file.

Here’s the basic usage:

local EvtD = require "EventDispatcher"

local dispatcher = EvtD()

-- listener as table
local listener = {
   eventName = function(event, ...)
      print(event.name, event.target, event.source)
   end
}

-- listener as function
local function listener(event, ...)
    print(event.name, event.target, event.source)
end

dispatcher:addEventListener( "eventName", listener ) -- or
dispatcher:on( "eventName", listener )

dispatcher:once( "eventName", listener )

dispatcher:hasEventListener( "eventName", listener )

dispatcher:dispatchEvent( { name="eventName" } ) -- or
dispatcher:dispatchEvent( "eventName" ) -- or
dispatcher:emit( { name="eventName" } ) -- or
dispatcher:emit( "eventName" )

dispatcher:removeEventListener( "eventName", listener )

dispatcher:removeAllListeners( "eventName" ) -- or
dispatcher:removeAllListeners()

dispatcher:printListeners()

All listeners receive the following fields in the parameter event table:

  • event.name (name of the event)
  • event.target (the listener itself)
  • event.source (the dispatcher)

Grab the latest code at Github.

Categories
Corona SDK Lua OOP

EventDispatcher update

Just a quick post that EventDispatcher has been updated with new features including new methods on(), emit(), once() that are similar to Node.js, a new method removeAllListeners(), and a debug function printListeners(). The on() and emit() methods are actually aliases to the addEventListener() and dispatchEvent() methods.

Chris Byerley (aka develephant) who developed Coronium.io and Coronium.gs is using EventDispatcher under the hood for the game server client code. Check out his projects if you’re a Lua / Corona developer.

Here’s the original post for EventDispatcher if you wish to read about it.

Grab the latest code at Github.