@GrahamRanson:
why does it return a table while lua can return 2 values for a function? It will increase readability and lines of code, ex: new_x, new_y = screenToWorldPosition(map, position)
as opposed to: new_x, new_y = unpack(screenToWorldPosition(map, position))
and unpacking is a performance hit, a big one. [import]uid: 11334 topic_id: 4422 reply_id: 15277[/import]
It returns a table simply because I am from an OOP background so that is what I am more used to, if people would prefer it to return 2 variables then that can be changed.
I just find objects (tables) easier as that way if I wanted for example to return other things in that table you wouldn’t need to change any of your code if you didn’t want to use that data.
I had also never used or even seen the unpack method before, I simply would access the variables via table.x and table.y
What is easiest for everyone? [import]uid: 5833 topic_id: 4422 reply_id: 15284[/import]
Graham,
I’m from a similar background so returning tables makes sense to me. However, I’m new to Lua and so don’t know if there is also a performance hit for calling table.x rather than using separate variables?
Cheers!
Rob
[import]uid: 12431 topic_id: 4422 reply_id: 15290[/import]
Yea some testing will need to be done to see if there are any performance hits.
I personally prefer the tables as that way if for any reason I decided to change the order or the return variables or add in new ones it wouldn’t break any of your code. The same goes for passing data to functions as well.
However I may own Lime but it is still a community based project so naturally if more people prefer multiple return variables or they offer some other tangible benefits then I will change to use them. [import]uid: 5833 topic_id: 4422 reply_id: 15298[/import]
Oh also, the API has been updated for the Utils functions:
http://justaddli.me/api.php?c=utils&m=worldToTilePosition
http://justaddli.me/api.php?c=utils&m=screenToTilePosition
http://justaddli.me/api.php?c=utils&m=screenToWorldPosition [import]uid: 5833 topic_id: 4422 reply_id: 15299[/import]
@GrahamRanson, tecnhohead2000:
unpack performance: http://trac.caspring.org/wiki/LuaPerformance (Test 3)
@technohead2000:
performance hit for referencing an index is very minimum e.g bla.x, it’s in the same performance test as above.
@GrahamRanson:
I shall then convince you from another angle! (I should be a lawyer)
Coding convention, even in Corona functions would return 2 values if it is meant to return 2 values, let’s observe exhibit A: http://developer.anscamobile.com/node/4356 or exhibit B: http://developer.anscamobile.com/reference/index/objectlocaltocontent
[import]uid: 11334 topic_id: 4422 reply_id: 15301[/import]
You make a good point, I will give it a proper think and return with my answer (most likely being a “best of both worlds” type answer)
But now back to the Beta Updates, I have just uploaded a new version - http://justaddli.me/downloads/builds/beta/LimeBeta1.1.zip - with a little bit of new code, basically it is an early test for parallax scrolling.
As I am still undecided I will put up this new version without any proper documentation and with the full expectation that it will not be what you guys want, but here goes anyway.
To get it to work you will first want to set up some background (or foreground) layers in Tiled (I plan to allow repeating blocks as well as pre-made images for these in the future) and then give them an “IsParallax” property as well properties for the parallax factor, these are “parallaxFactorX” and “parallaxFactorY”, you will probably want these between 0 and 2 but give it a go and play, you can also leave out either one of the values to lock the player on that axis (so if you don’t the layers to move up and down just leave out the Y factor)
You will most likely want lower values for the layers that are further away making them move slower then layers that are closer to the camera with higher values.
To get it to work in game you currently just have to call the following function:
lime.setParallaxPosition(map, x, y)
You can pass nil as the X or Y parameter if you wish which will mean the layers wont scroll on that axis.
You could then use this on a tap/touch event or in an update method like so:
local update = function(event)
lime.setParallaxPosition(map, player.x, nil)
end
Please give this a go and provide any feedback you can as well as any suggestions on how this could be implemented if you can think of a better way.
Please note: Currently parallax layers are NOT added to the main map group meaning that if you call map:move() or any other functions where you change the position of the main map group such as via transition.to the parallax layers will not move as well, this is one of the things that I would like to hear your thoughts on. [import]uid: 5833 topic_id: 4422 reply_id: 15303[/import]
Hi Graham,
have you looked at Cocos2D much (in particular the parallax stuff)? i’m sure there implementations of Parallax scrolling etc have had much though and user input put into them, so might be a good structure to look at?
http://www.cocos2d-iphone.org/api-ref/latest-stable/interface_c_c_parallax_node.html
http://www.cocos2d-iphone.org/archives/22
http://www.cocos2d-iphone.org/forum/topic/3414
there’s also features we can be requesting from Ansca maybe such as the GL REPEAT
http://www.learn-cocos2d.com/knowledge-base/cocos2d-iphone-faq/learn-cocos2d-public-content/manual/cocos2d-general/14538-how-to-draw-an-endlessly-repeating-parallax-background/
regards
J.
[import]uid: 6645 topic_id: 4422 reply_id: 15380[/import]
It looks like they’ve done a similar thing, I guess we will only find out what is right for Corona/Lime once people start playing with it.
Yea that GL REPEAT looks perfect, exactly what I would need for the background layers. [import]uid: 5833 topic_id: 4422 reply_id: 15408[/import]
Parallax as it is works perfectly.
Edit. My TileMap is based on a 80x80 system. I made a huge png background at 640,960 and added that to my map as new tileset. I find that you can still put it in a parallax layer and get it to work!!! Well done! [import]uid: 11904 topic_id: 4422 reply_id: 15526[/import]
Awesome, very glad to hear it. That will allow me to clean up the implementation a bit and get to work on extra things like using pre-made images etc. [import]uid: 5833 topic_id: 4422 reply_id: 15528[/import]
Well, thats what I’m saying. You can take any premade image and load it into Tiled as a parallax layer and it will work. Not sure if you need to do anything more for premade images. Just make sure they are smaller than 999 by 999 pixels as this is the max Tiled will allow for each tile size. [import]uid: 11904 topic_id: 4422 reply_id: 15530[/import]
Can’t seem to get 2 layer Parallax to work. I used duplicate later function in Tiled and then changed the visual but I only get the first layer when I execute my app. Is there anything I need to do to get the second layer going?
My bad. Its working. [import]uid: 11904 topic_id: 4422 reply_id: 15534[/import]
Oops, I posted my reply before I saw your edit. All I was going to do was allow a blank layer to have something like an “image” property but your method is a much more intuitive method! [import]uid: 5833 topic_id: 4422 reply_id: 15554[/import]
I subscribe to the KISS philosophy. [import]uid: 11904 topic_id: 4422 reply_id: 15555[/import]
Hi Graham,
I am way behind on my Lime update but I am afraid to update because of the performance impact, is there any update on Lime’s performance? [import]uid: 11334 topic_id: 4422 reply_id: 15557[/import]
The KISS philosophy is a good one. Both for programming and music choice.
At present there have been no real improvements in performance so you should be free to update but naturally keep a back up just in case. I hope to have some good news on the performance front soon. [import]uid: 5833 topic_id: 4422 reply_id: 15560[/import]
New version is up - http://justaddli.me/downloads/builds/beta/LimeBeta1.2.zip
In this version is the fix to multiple tilesets as well as the tile properties bug.
Note: There is one limitation to external tilesets that I hope to resolve, for some reason they cant have hyphens in their names. [import]uid: 5833 topic_id: 4422 reply_id: 15610[/import]
To go along with the new version, here is the tutorial on animated characters - http://justaddli.me/tutorial.php?t=0&id=11 [import]uid: 5833 topic_id: 4422 reply_id: 15614[/import]
A new build is up - http://justaddli.me/downloads/builds/beta/LimeBeta1.3.zip
In this are modified camera movement functions, please note that these changes *may* mess up your current project, I am really sorry for any possible problems caused. If you do have any please post on here or email me and I will help you sort them out.
I have also written a nice and simple tutorial to go along with the map movement functions - http://justaddli.me/tutorial.php?t=0&id=13 [import]uid: 5833 topic_id: 4422 reply_id: 15944[/import]