Comign from Corona I was used to changing a display objects (Bitmap, Textures is that what they are called here?) locations simply by changing their ".x" and ".y" properties. Is there a way to do that with Gideros instead of "setX()". I have devised a way using EnterFrame listeners but I do not think it is very performance efficient.
Comments
How this :
Is a layer made by @OZApps that should accomplish that if you really want, but as there are minor syntactical differences when switching between any languages etc it may be good to learn this new way as well. I'm not sure how his tool does it, but I'm guessing you could also use metatables to perform a function when the value is read and a different function when it is set to accomplish that.
best regards
Likes: hgvyas123
https://play.google.com/store/apps/developer?id=Into-It+Games
http://appstore.com/LidiaMaximova
"new word invented can be used when any person says 110% true things"
from the movie (bollywood)
One thing I'd like is the ability to access sprite children using indexing e.g.
menu:getChildAt(i):addEventListener(Event.MOUSE_DOWN,gotolevel,menu:getChildAt(i))
could be written
menu[i]:addEventListener(Event.MOUSE_DOWN,gotolevel,menu[i])
Much more readable!
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
Likes: SinisterSoft
I found this thread because I was *exactly* looking for the same:
- Using .x / .y instead of the inconvenient :setX() / setY() methods.
- Easily accessing a sprite's children using MySprite[2] instead of MySprite:getChildAt(2)
While porting a big amount of code from Corona to Gideros, I found that using .x, .y, Sprite[n] is much cleaner, easier to maintain code. The Gideros ported code looks pretty much "spaghetti like" compared to the original.
With Corona, I used to do things like this:
MySprite[6].isVisible = showMe > 0 and true or false
It's short, easy to read any convenient. Is there any way / workaround to extend Gideros Sprite and Bitmap so we can use .x, .y, .isVisible etc. instead of the clumsy setter / getter functions?
You need those setters / getters literally hundreds of times, so shorter notations makes a big difference (and it really looks cleaner) in my own opinion.
well usually if someone asked to use MySprite[2] instead of MySprite:getChildAt(2), I'd say you are using it wrong.
But since you are in process of porting, thats completely understandable.
you can achieve MySprite[2] through __index metamethod and .x / .y through __newindex
Here are more on this topic:
http://lua-users.org/wiki/MetamethodsTutorial
http://lua-users.org/wiki/MetatableEvents
So basically you could try something like this (but be warned, that it is a slower process than setter methods):
https://play.google.com/store/apps/developer?id=Into-It+Games
http://appstore.com/LidiaMaximova