Skip to content

Instantly share code, notes, and snippets.

@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
@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 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 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 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 20:31
Corona SDK: Adding Sound Effects
--load your sound effect near the beginning of your file
local mySoundEffect = audio.loadSound("mySound.mp3")
--To play the sound effect, call this whenever you want to play it
audio.play(mySoundEffect)
-----------------------------------------------------------------------------------------
--
-- main.lua
--
-----------------------------------------------------------------------------------------
-- Your code here
local myMole=display.newImageRect("images/mole_1.png",178,200)
@shawngrimes
shawngrimes / minim_input_test
Last active August 29, 2015 14:13
Testing using audio inputs and mapping that to a color.
import ddf.minim.*;
import ddf.minim.analysis.*;
float myOpacity;
float getVolume;
int mappedVolume;
Minim minim;
AudioInput in;
if( in.isMonitoring() ){
ellipse(50,400,55,55);
}

Keybase proof

I hereby claim:

  • I am shawngrimes on github.
  • I am shawngrimes (https://keybase.io/shawngrimes) on keybase.
  • I have a public key whose fingerprint is 8C8B F893 1135 A62F 33BC B48F 7A42 4C82 0E4C 6058

To claim this, I am signing this object: