Skip to content

Instantly share code, notes, and snippets.

@shawngrimes
shawngrimes / main.lua
Created October 20, 2012 18:44
Corona SDK: Moving a Rocket Mouse with Physics
--Load Physics Library
local physics = require "physics"
--Show physics drawing lines, for help with debugging
physics.setDrawMode( "hybrid" )
--Start Physics
physics.start()
@shawngrimes
shawngrimes / main.lua
Created October 20, 2012 17:54
Align Bottom Right
--Change the reference point of the object
myObject:setReferencePoint(display.BottomRightReferencePoint)
--This will add a buffer of half the objects width, if you want it flush with the
--right, change it to myObject.x=display.contentWidth
myObject.x=display.contentWidth - myObject.contentWidth/2
--This will add a vertical buffer of half the object's height, if you want it flush with the
--bottom, change it to myobject.y=display.contentHeight
@shawngrimes
shawngrimes / main.lua
Created October 20, 2012 17:53
Move an object to the bottom left
--Change the reference point of the object
myObject:setReferencePoint(display.BottomLeftReferencePoint)
--This will add a buffer of half the objects width, if you want it flush with the
--left, change it to myObject.x=0
myObject.x=0 + myObject.contentWidth/2
--This will add a vertical buffer of half the object's height, if you want it flush with the
--bottom, change it to myobject.y=display.contentHeight
myObject.y=display.contentHeight - myObject.contentHeight/2
@shawngrimes
shawngrimes / main.lua
Created October 20, 2012 16:25
Corona Scrolling Backgrounds Sample
--This is a work in progress
--Create the first background
local myBackground=display.newImage("background1.png")
myBackground:setReferencePoint(display.CenterLeftReferencePoint)
myBackground.x=0
--Create the second background
local myBackground2=display.newImage("background2.png")
myBackground2:setReferencePoint(display.CenterLeftReferencePoint)
@shawngrimes
shawngrimes / main.lua
Created October 20, 2012 15:53
Create a Button with Corona SDK
--This adds the widget library to our project
local widget = require "widget"
--This is what is run when we press our button
local myButtonEvent = function (event )
if event.phase == "release" then
print( "You pressed and released the "..event.target.id.." button!" )
end
end