Giter Club home page Giter Club logo

flsprite's Introduction

#FLSprite

FLSprite is a CoronaSDK class for Adobe Flash CS6+ SpriteSheet JSON-Array Output.

How to create sprite sheet in Flash CS6+
http://helpx.adobe.com/flash/using/create-sprite-sheet.html

##How to use? Select those clips in Library and right click the Generate Sprite Sheet... in Adobe Flash CS6+.

Choose JSON-Array for the output data format.

Converts JSON file to UTF-8 encoding.

Adobe Flash sprite sheet json file output is a UTF-16 encoding text file. Remember to encode it to the UTF-8. Otherwise, CoronaSDK will get an error of it. If your are using Sublime Text editor. You can find the Save with Encoding function in dropdown menu File.

UTF-16 to UTF-8 online converter

##Usage:

local FLSprite = require "FLSprite"

-- FLSprite.load( jsonPath [,optional: system path ][, optional: isPreload boolean ] )
-- local sheetInfo = FLSprite.load("demo.json")
-- isPreload=true,  preload texture in memory
local sheetInfo = FLSprite.load("demo.json", true)
local sheet = sheetInfo:getImageSheet()

New Image

-- newImage
local girl = display.newImage( sheet, sheetInfo:getFrameIndex("Character Horn Girl.png" ))
girl.x = 100; girl.y = 100

New ImageRect

-- newImageRect
local frameIndex, frameData = sheetInfo:getFrameData("Character Horn Girl.png")
local girl1 = display.newImageRect( sheet, frameIndex, frameData.width, frameData.height )
girl1.x = 180; girl1.y = 100

###Sprite

-- sprite
local data = sheetInfo:getSequenceData("ppl01_act1")
-- rewrite loopCount, default is loop
data.loopCount = 3
-- rewrite loopDirection
data.loopDirection = "bounce"
local sp = display.newSprite( sheet , data )
sp.x = 180; sp.y = 240
sp:play()


-- sprite for all actions
local index = 2
local data1 = sheetInfo:getSequenceData()
local sp1 = display.newSprite( sheet , data1 )
sp1.x = 120; sp1.y = 320
sp1:play()

local function swapSheet()
    sp1:setSequence( "ppl01_act"..index )
    index = index==2 and 1 or 2
    sp1:play()
end

timer.performWithDelay( 2000, swapSheet, 0 )

###Clear cache -- remove all groups and then... FLSprite.clear("demo.json")

--clear all caches
FLSprite.clear()

flsprite's People

Contributors

erinlin avatar

Watchers

 avatar James Cloos 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.