Introducing Lime - A module to import 2D tilemaps in your game.

It shouldn’t really make any performance odds how big the maps are if programmed correctly. As long as the only tiles being rendered/animated at any given time are those only within the screen bounds, it should make no performance issue no matter how big the map is.

(I am speaking from experience) [import]uid: 6981 topic_id: 3598 reply_id: 12066[/import]

@jtal

Sorry for the late reply, been busy with other Corona projects but have also been adding lots more to Bounty (namely Banana) and will look into proper source control soon.

@infuseddreams

That is the plan yea, it really shouldn’t matter if the map is 10*10 or 1000*1000. Do you have any advice on efficiency of having lots of sprites? What are the best ways of dealing with them if I have say 1000 created but only 10 being drawn at a time? [import]uid: 5833 topic_id: 3598 reply_id: 12073[/import]

as i suggested before… whether it is one big display group for the whole map or scrolled by updating a subset of tiles, really wants to be a user option. For a map that is 2 screens high and 2 screens wide for instance I’d probably use the former option of having it as a single display group and let corona do the grunt work (as per your initial test examples).

[import]uid: 6645 topic_id: 3598 reply_id: 12094[/import]

Just a quick question, does anyone know what happens to sprites (and physics objects) when they go off the screen? Does Corona still draw them or will it automatically stop drawing them? Basically, do I have to worry about setting things invisible when they leave the screen? [import]uid: 5833 topic_id: 3598 reply_id: 12109[/import]

in the docs it mentions something about them still being in the display list if they’re visible. moreover if they’re animated sprites it still runs the animation code on them. therefore really you want to set them to invisible… but you should try out my performance test, as i found some odd results with this when setting isvisible to false. it actually slowed down. but i did have a lot of objecvts

http://developer.anscamobile.com/forum/2010/11/13/performance-tip-setting-isvisiblefalse-slow-reading-display-object-xy-slow

also did you have any thoughts about non-tilemapped stuff that i mentioned here?
http://developer.anscamobile.com/forum/2010/11/22/scrolling-large-non-tiled-world-objects

basically a few 1000 objects over a large area being turned on dynamically (originally set to visible false), but not being turned off, performed quite well. One thing i didnt do there though was optimize which chunk of objects i should check to see whether they should be visible or not. I just checked the whole lot which seems unnecessary. for a fixed tile map where objects dont move presumably you only need to check items just outside the screen area

thanks
J [import]uid: 6645 topic_id: 3598 reply_id: 12111[/import]

Graham,

Strille posted quite a good approach to screen scrolling for Flash http://www.strille.net/tutorials/part1_scrolling.php

if you’ve seen his Sonic Demo, you’ll know this works quite well
http://www.strille.net/works/misc/platform_demo/

I’m going to have a look at this and how it relates to optimizing corona scrolling in certain setups.

it might be a better solution to my question here http://developer.anscamobile.com/forum/2010/11/22/scrolling-large-non-tiled-world-objects

although I’m still not sure what to do when physics is involved as presumably i don’t really want to temporarily remove a physical item until it has become static and no longer involved in collisions

j [import]uid: 6645 topic_id: 3598 reply_id: 12411[/import]

That looks perfect! Thank you for finding this.

Just so everyone knows, I have been working on Bounty over the past week regardless of me being fairly quiet on the forum, it’s just that I’ve also been working on Tuucha and preparing for some possible contract work.

The other thing to mention is that I am considering the possibility of selling Bounty for a small fee when it actually gets to a fully usable state (i.e. the requirements that we’ve mentioned above and whatever else people can reasonably ask for). My first question is would people be willing to pay a small fee for it and if so what would they expect for whatever price they pay? [import]uid: 5833 topic_id: 3598 reply_id: 12449[/import]

Hi Graham,

setting up levels in a game like this would be ideal for TILED/Lime:
http://www.donutgames.com/play/lucky_coins

but I wouldn’t want to have to set the property values on objects for every instance, therefore it would be good if the parser allowed you to define behaviour based on the index of the tile graphic (or however it is referenced). Will i be able to easily get the tile type from the map data? (eg 1 = star, 2 = small star, 3 = large bumper, 4 = small bumper, 5 = hole etc)

Also would varied size objects need different layers? (eg the circular bumper is 4 tiles in size, but actually i would only want to define it as one tile, rather than 4 separate corners)

I’m guessing that Corona could cope with this game as 1 big display group (containing various sub-layers), although I’ve not tested the limits of scrolling a multi-screen set of sprites)

thanks
J [import]uid: 6645 topic_id: 3598 reply_id: 12450[/import]

Particle Candy is a pay-for library and presumably is a pure lua implementation? (unless X-Pressive have worked with Corona to implement a C module)

so it’s not unfair that Bounty might be chargeable, but I think you should probably speak with Ansca and check

  1. what they have in store regarding TileMaps etc
  2. whether they could commission your work

also I think people would want some good (basic) working examples of the various features included in the package before purchasing

of course we would like it all for free, but useful, timesaving, quality products are worth contributing to.

J [import]uid: 6645 topic_id: 3598 reply_id: 12451[/import]

That’s a nice little game you found there :slight_smile:

For setting the star values (or anything like that) I would use the Property features of Tiled, you can give a tile in the Tileset a property (for instance the name would be Score and the value would be 5) that way every tile you create of that image with automatically have that property in your game (Lime parses them all and then Coconut adds them to the tile when the sprite is created)

With the properties on the tile you could then have a onCollision event get fired on the ball and then when you have the Tile object from the collision you could then get the Score property - tile:getProperty(“Score”) - and add it to your level score.

As for larger tiles, as far as I’m aware that would need separate layers in Tiled.

Yea I reckon Corona could deal with maps of that size, and would be a nice test. [import]uid: 5833 topic_id: 3598 reply_id: 12454[/import]

It was actually Ansca that asked me if I was planning on selling Lime :slight_smile: I had always considered it a remote possibility but never thought that I even could do that or that anyone would even be interested in using Bounty, let alone paying for it :slight_smile:

Yea I’m planning on having lots of sample apps/projects made with it with proper documentation etc, currently while I have been working on the Banana (physics) part of it I have seen how easy it would be to set up a 2D Platformer level.

Basically I will keep working on it and releasing info about what I am doing and releasing samples etc and see what people think about it and if they would consider paying for it.

I will also talk more with Ansca to see what they think about it. [import]uid: 5833 topic_id: 3598 reply_id: 12455[/import]

The properties are created for individual tiles in a tileset and then when the tile is created Coconut will pull out the correct properties so that each instance of a tile in the game has the correct properties applied to it.

If you want specific tiles to have different properties rather than just the same as every instance then you could so something like create an Object on an ObjectLayer that acts as a sort of spawn point for a certain object/tile/player etc with all the properties getting pulled over by your code.

In a simple demo I am putting together for a Platformer this will be how players, enemies and pickups etc are spawned.

Also, as you have been very helpful in the creation of Bounty so far would you like a special uber secret preview of the updates I have been working on now? As I am considering taking this commercial I figure I should probably hold off on any public releases until I find a way of protecting the code. [import]uid: 5833 topic_id: 3598 reply_id: 12463[/import]

ah i didn’t realise that the property is on the tile in the spritesheet rather than a tile instance in the map. Is there a way to add a specific property to a specific map instance of a tile also used elsehwere? or in that case would i best adding an invisible layer.

ps if you look up Donut Games on the App Store they have that game and a few others which are good examples of where a tilemap, physics and scrolling could be implemented. (basically aim & bounce games…simple but addictive)

Monkey Flight
http://itunes.apple.com/us/app/monkey-flight-lite/id314826459?mt=8
http://www.donutgames.com/play/monkey_flight

Spikey’s Bounce Around
http://itunes.apple.com/us/app/spikeys-bounce-around/id328206413?mt=8
http://www.donutgames.com/play/spikeys_bounce_around

Lucky Coins
http://itunes.apple.com/us/app/lucky-coins/id310068841?mt=8
http://www.donutgames.com/play/lucky_coins

Ruberth’s Kick and Fly
http://itunes.apple.com/us/app/ruberths-kick-n-fly/id343637120?mt=8
http://www.donutgames.com/play/ruberths_kick_n_fly
j [import]uid: 6645 topic_id: 3598 reply_id: 12460[/import]

Do you find scrolling is very jerky in the simulator and also jerky on the device? [import]uid: 9371 topic_id: 3598 reply_id: 12464[/import]

The jerkiness is most likely down to the framerate, for now stick with smaller maps but I am looking into ways (such as those listed by jmp909 above you) to allow for much larger maps with a consistent (and playable) framerate. [import]uid: 5833 topic_id: 3598 reply_id: 12468[/import]

a good point to note from one of the previous posts is that when you scroll a map, if the tile at (X+1, Y) for instance is the same type as the tile at (X,Y), then you can skip the redraw as it’s a wasted operation. Whether corona does this for you automatically (if you’re setting currentFrame on the sprite to the same value) i don’t know

[import]uid: 6645 topic_id: 3598 reply_id: 12477[/import]

Graham,

did you come to any conclusions on this “isVisible=false” performance issue?
http://developer.anscamobile.com/forum/2010/11/13/performance-tip-setting-isvisiblefalse-slow-reading-display-object-xy-slow

[import]uid: 6645 topic_id: 3598 reply_id: 12502[/import]

I haven’t yet come to a firm conclusion but I also don’t have a working iPhone right now (as of a couple of days ago) which is quite annoying so can’t test things properly anymore.

However surely by never hiding things after showing them the game would get gradually slower? [import]uid: 5833 topic_id: 3598 reply_id: 12507[/import]

you’d think… but check this
http://www.sendspace.com/file/0qnfnn

there are 2 parts that confuse me

  1. it has been suggested that reading tile.x has to put it through some extra calculations for reference point etc, which might explain this one
    [lua]-- **************************************************************
    – reading (custom var) tile.xpos is quicker than reading tile.x!
    – ***************************************************************
    – tileX = tile.x + mapX
    tileX = tile.xpos + mapX[/lua]

  2. but this doesn’t seem to make sense
    [lua]if(leftcheck and rightcheck) then
    tile.isVisible=true
    else
    – *************************************************
    – ***** why does this line slow it down!!! ****
    – *************************************************
    –tile.isVisible=false [/lua]

my only guess is that it’s something to do with Corona’s internal double buffering and that by creating so many display objects it can’t fit it into the GPU in one go so has to swap elements about. from what i could tell setting isVisible = false performs an operation even if it is not needed, so in this case leaving it out leads to better performance

bear in mind this is only tested in the simulator though [import]uid: 6645 topic_id: 3598 reply_id: 12509[/import]

To ensure that it only gets set to false when needed could you change it to this -

  
if(leftcheck and rightcheck) then  
 tile.isVisible=true  
elseif(tile.isVisible) then   
  
 tile.isVisible=false   
end  

But then that extra check might itself slow things down :slight_smile:

-Edit-

Just tested that small change, it keeps it at around 60 apart from jumps down to 30 every couple of seconds so better than just setting it to false, but not great. [import]uid: 5833 topic_id: 3598 reply_id: 12511[/import]