Skip to content
forked from ldurniat/Berry

Berry is a simple Tiled Map Loader for Corona SDK.

License

Notifications You must be signed in to change notification settings

roaminggamer/Berry

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

berry

berry is a simple Tiled Map Loader for Corona SDK.

Screenshot of berry in action

berry supports only part of functionality offered to user by Tiled. This includes tile and object layers, tilesets and collections of images. Neverthless it can be extended by using custom properties and executing custom code to gain more flexibility and control.

List of features:

  • Loads .JSON export from www.mapeditor.org
  • Adds basic properties from Tiled including physics
  • Supports object layers and tile layers
  • Supports collections of images and tileset images
  • Supports object x/y flipping and re-centering of anchorX/anchorY for Corona
  • Supports object animations using Corona sequences
  • Rectangle shape with fillColor and strokeColor support
  • Supports custom collision shapes. Only rectangles and polygons for now
  • Supports Text object

Quick Start Guide

berry = require( 'pl.ldurniat.berry' )
local map = berry.loadMap( filename, tileSetsDirectory )
local visual = berry.createVisual( map )
berry.buildPhysical( map )

filename

The filename specify path to file with map.

Saved Map

tileSetsDirectory

Most of the time you will store you maps and images/tilesets in a directory. The tileSetsDirectory parameter overides where berry looks for images.

local map = berry.loadMap( 'scene/game/map/sandbox.json', 'scene/game/map' ) -- look for images in /scene/game/map/

map

The map object exposes methods to manipulate adn find layers, objects and tiles. See documentation for more information.

map.designedWidth and map.designedHeight are the width and height of your map as specified in tiled's new map options. The map will be centered on the screen by default.

Character in game

visual

berry returns a group object that contains all the layers, objects and tiles for the exported map.

Extensions

map:extendObjects( types )

The extendObjects() function attaches a lua code module to a image object. You can use this to build custom classes in your game.

Custom Properties

The most exciting part of working in Tiled & Corona is the idea of custom properites. You can select any image object on any object layer in Tiled and add any number of custom properties. berry will apply those properties to the image object as it loads. This allows you to put physics properties, custom draw modes, user data, etc. on an in-game item via the editor.

Note: Tile properties will not be inherited by objects so you have to add it to objects itself with the exception of animation properties.

Custom Properties

hasBody

One special custom property is hasBody. This triggers berry to add a physics body to an object/tile and pass the rest of the custom properties as physics options. Rectangle bodies are currently supported by default, adding a radius property will give you a round body. More complicated shape you can obtain by using the Collision Editor. No all shapes are supported.

Setting a hasBody property

isAnimated

One more special property you may want to use is isAnimated. This triggers berry to replace simple image object with animation created in Tiled using the Animation Editor.

Setting a isAnimated property

Debug information

To gain some useful information about what is going on use berry:enableDebugMode() and berry:enableDebugMode() methods. If debug mode is enabled berry print out simple messages what he is doing. Use berry:isDebugModeEnabled() to check if debug mode is currently enabled or disabled.

Example

See Sticker-Knight-Platformer and wiki.

What's next

  • Support for isometric maps
  • Support for hex maps
  • Collision filter
  • Parallax effect
  • Camera effect
  • Support for external tilesets
  • Support for custom object types
  • Support for multi-element bodies

Donations

If you think that any information you obtained here is worth of some money and are willing to pay for it, feel free to send any amount through paypal. Thanks :)

paypal

Contributing

If you have any idea, feel free to fork it and submit your changes back to me.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Acknowledgements

berry is inspired by projects like ponytiled and lime.

About

Berry is a simple Tiled Map Loader for Corona SDK.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%