This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local group = display.newGroup() | |
group:translate(display.contentCenterX, display.contentCenterY) -- move the group to the center of the screen | |
local baseImage = display.newImage(group, "base-image.png") -- draw the yellow circle image & add to group | |
local mask = graphics.newMask('example-mask.png') -- draw a mask | |
group:setMask(mask) -- set the mask on the group | |
transition.to( baseImage, { time=1000, x=180 } ) -- move the image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local path = display.newImage( "Images/WorldMap/path/level2.png") -- base image (yellow line) | |
local mask = graphics.newMask( "Images/WorldMap/path/level2-mask-0.jpg" ) -- base mask (completely black) | |
path:setMask( mask ) | |
local ctr = 0 | |
local iterations = 38 -- number of mask images in animation sequence | |
local function mask( event ) | |
ctr = ctr + 1 | |
path:setMask( nil ) -- remove the previous mask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function zIndexCharacters() | |
local function redraw() | |
-- images are all held in an allImages array | |
for image = 1, #allImages do | |
allImages[image]:toBack() | |
end | |
end | |
local function compare( a, b ) | |
return a.y > b.y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"unitType" : "ground", | |
"classType" : "melee", | |
"characterType" : "pc", | |
"allowableMoves" : 3, | |
"maxLife" : 50, | |
"animations":[ | |
{ | |
"baseSE": | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local sheetInfo = require("knight") | |
local myImageSheet = graphics.newImageSheet( "knight.png", sheetInfo:getSheet()) | |
local sequenceData = | |
{ | |
name="rotate", | |
start=1, | |
count=8, | |
time=1000, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- taken from http://coronalabs.com/blog/2013/09/10/modernizing-the-config-lua/ | |
--calculate the aspect ratio of the device | |
local aspectRatio = display.pixelHeight / display.pixelWidth | |
application = { | |
content = { | |
width = aspectRatio > 1.5 and 800 or math.ceil( 1200 / aspectRatio ), | |
height = aspectRatio < 1.5 and 1200 or math.ceil( 800 * aspectRatio ), | |
scale = "letterBox", | |
fps = 30, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- update the damage bar | |
function updateDamageBar() | |
damageBar.x = currentHealth / 2 | |
damageBar.width = maxHealth - currentHealth | |
end | |
-- lower the character's currentHealth | |
function damageCharacter(damageTaken) | |
currentHealth = currentHealth - damageTaken | |
updateDamageBar() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- create green health bar | |
healthBar = display.newRect(0, | |
-45, | |
maxHealth, | |
10) | |
healthBar:setFillColor( 000/255, 255/255, 0/255 ) | |
healthBar.strokeWidth = 1 | |
healthBar:setStrokeColor( 255, 255, 255, .5 ) | |
characterGroup:insert(healthBar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- add a group to contain the character and healthbar | |
characterGroup = display.newGroup( ) | |
characterGroup.x = display.contentCenterX | |
characterGroup.y = display.contentCenterY | |
-- set maxHealth and currentHealth values | |
maxHealth = 100 | |
currentHealth = 100 | |
-- draw a character to the screen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- find the path from point A to point B | |
function getPath() | |
-- create a Jumper Grid object by passing in our map table | |
local grid = Grid(map) | |
-- Creates a pathfinder object using Jump Point Search | |
local pather = Pathfinder(grid, 'JPS', walkable) | |
pather:setMode("ORTHOGONAL") | |
-- Calculates the path, and its length |
NewerOlder