Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Extending Gideros - Page 2 — Gideros Forum

Extending Gideros

2456

Comments

  • atilimatilim Maintainer
    edited September 2012
    @ar2rsawseen uhh.. you're right: The behavior of next is undefined if, during the traversal, you assign any value to a non-existent field in the table. You may however modify existing fields. In particular, you may clear existing fields.
  • Wow I really like this idea, but then again I prefer LUA based libraries where possible since they work on both iOS and Android anyway :) Cool stuff, can't wait to see how this turns out.
    ThumbHurt Games / FB: ThumbHurt Games / FB: Eli/Teranth | Skype: teranth37
  • Ok commited modified version. Hopefully tomorrow will add more functionality ;)

    But keep posting suggestions here, I will look at all of them :)
  • @ar2rsawseen, @atilim and everyone else involved in this.
    As I posted the other thread mentioned in the first post - I just thought I ought to jump in aa some point and say what an inspired bit of work this is, still trying to get my head around some of the lower level Lua "fiddly bits", but it looks like some really useful code.

    Time to get my reading head on :)
    WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
    #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
  • ar2rsawseenar2rsawseen Maintainer
    edited October 2012
    Updated the project, now includes some basic physics abstraction and included bunch of @bowerandy functions and probably something else I can't remember right now.

    So if someone wants to get their hands dirty, here's a bunch of stuff you can research and provide code for, that would help us a lot.

    Chain everything
    Explanation:
    Right now most of the methods are chained, meaning they return they object (if not returning anything else) for shorter code writing. But still not all possible methods are chained. So the task is, either come up with set of keywords inside methods' name, that would cover up most of the methods (but will not cover methods that actually return something) and chain others manually.
    Or come up with different approach how this can be done, for example, checking bytecode in function body for return command

    RGB to hex conversion and vice versa
    Explanation:
    Now this might be to obvious thing to do, but I'm too tired right now to try and figure it out, so I'll post it here.
    If we want to, for example, support HSL color model, there is a need to be able to convert 255, 255, 255 to 0xffffff and back, since Gideros accepts color in 0xffffff format.

    Taking and implementing any feature of the list
    Explanation:
    There are features list in the first post, that should be included in init.lua. Implement them, share the code, or extend existing features ;)

    Test, test, test
    Explanation:
    While writing I do some initial test if this works at all or not. But more thorough testing is needed. For example, including this init.lua should not only provide additional functionality, which works properly, but also not to mess up with existing code, aka, provide full backwards compatibility

    Provide feedback
    Explanation:
    Provide feedback on existing implementations, if many of you say something is needed, it will be included, if many says it's not needed it can be removed. But that's not all. Also consider function names, optimizations and other aspects, for example, creating abstraction layer for physics, in many cases I need to think for user and make decisions for them, just to make code shorter and easier. I'm not a dictator and don't want to make decision for all, let's make it more democratic and let's hear your thoughts

    Suggest new features
    Explanation:
    This lib will be as good as there are features in it. If there is something you use, or something you think would ease the development or simply some functionality that would have helped you, please post. Provide idea and we will be grateful, provide also a code and you will be my hero (@atilim already is :) )

    Likes: gorkem, Mells

    +1 -1 (+2 / -0 )Share on Facebook
  • Hello,

    Just getting a chance to look at this now - Great Stuff =D>

    At first glance It looks like line 541 should be changeAllSetFunctions(SoundChannel)

    If I get a chance I'll delve a little deeper. What with this and the Hot Wax stuff from Andy, there's not enough time in the day (thanks to the boring day job :(()

    cheers

    evs
  • You are completely right @evs, I've corrected it ;)
  • ar2rsawseenar2rsawseen Maintainer
    edited September 2012
    Updated repo:
    Enhanced Box2d methods, fixed some bugs
    Implemented setting AnchorPoints for all Sprite inherited classes
    Implemented baseline fix for TextFields, now positioning of TextField should be correct as expected
    ;)
  • zvardinzvardin Member
    edited September 2012

    Find a way to set up callback for requiring specific library
    Explanation:
    I have created basic physics abstraction (will continue to work on it), but not every game needs physics. So it would be helpful to set a call back inside init.lua file, when someone requests box2d library, to execute code and add additional functionality provided
    Could you do something like:
    setmetatable(_G, {
        __newindex = function(t,k,v) 
            if(k=="b2World") then
                print("added b2")
                setmetatable(_G, {})
            end        
        end})
    Might want to do it a little better to revert metatable etc. but just a guess!
  • @ar2rsawseen
    Thank you for your work on this project.
    twitter@TheWindApps Artful applications : The Wind Forest. #art #japan #apps
  • ar2rsawseenar2rsawseen Maintainer
    edited October 2012
    Updated repo added some shape methods and some fixes to box2d methods.

    @zvardin Have never worked with setmetatable before, could you please elaborate more on this :)
  • I haven't used it too much myself (other than setting a table to be weak by key instead of value), but basically you can provide some functions to change how things work for that table. In this case, __newindex is called whenever a new index to the table is accessed. It receives 3 parameters (the table referenced, the key being accessed and the value). b2World is one of the indices added when requiring box2d, so I checked for that.

    There could be some pitfalls I'm not aware of, but I did do a test and the print statement in the above example gets executed when I required box2d.

    for reference: http://www.lua.org/pil/13.4.2.html

    Actually, after looking at this you would need to include a line to add the b2World still, so: t[k] = v

    If we're assuming this init.lua is always firing first we wouldn't have to worry too much about some other scenarios, but to be safer we could probably try to chain the function doing something like:
    local oldNewindex
    local mt = getmetatable(_G)
    local bDestroyMT = not mt
     
    local function ni(t,k,v)
       if k == "b2World" then
          t[k] = v
          --run code here for physics engine added
     
     
          --clean up
          if bDestroyMT then
             setmetatable(_G, {})
          elseif oldNewindex then
             -- we still need to fire the original __newindex function
             oldNewindex(t,k,v)  
             mt.__newindex = oldNewindex
          else
             mt.__newindex = nil
          end
       end
    end
     
    if not mt then 
       mt = {} 
    elseif mt.__newindex then
       oldNewindex = mt.__newindex
    end
     
    mt.__newindex = ni
     
    setmetatable(_G, mt)
  • ar2rsawseenar2rsawseen Maintainer
    edited October 2012
    Ok this might work.
    But I've tried it, and including b2world: t[k] = v raises a C stack overflow, and of course without that line b2world is not included.

    Could this be possible that setting t[k] = v calls up __newindex again and it all goes in to recursive eternal loop?

    Thus I've tried setting up using rawset(t, k, v), but which gives me global b2 is nil. Which could mean that there is a problem with loading order or I just mess all the things up internally. Kind of feeling poking blindly here :)
  • zvardinzvardin Member
    edited October 2012
    It comes to mind I may have overlooked the simple answer...
    local _require = require
    require = function(name)
            _require(test)
    	if name == "box2d" then
               -- do stuff here
     
               require = _require
            end
     
    end
    That would also add a lot less overhead.
  • Updated repo, included
    @zvardin provided fix for loading box2d extensions
    Created methods for setting absolute positions for sprite (including named positions as top, bottom, left, right, center)
    Created method to get absolute dimensions for application
    Created a method isPlaying for Sounds
    Creating application:setVolume/getVolume to control volume of all sounds
    in application
  • init.lua (483) if type(arg[1] == "string") then
    => if type(arg[1]) == "string" then

    init.lua (502) - the same
  • Thanks @asakharov fixed it.
    Now I wonder how come it worked :D
  • ar2rsawseenar2rsawseen Maintainer
    edited October 2012
    Added call for help tasks:
    Show child behind the parent or not inherit alpha and
    Determine the font type
    to the first post

    Updated repo:
    Implemented shadows for TextFields
    Implemented global application enableFiltering to automatically enable anti-alizing for all Textures and fonts
  • ar2rsawseenar2rsawseen Maintainer
    edited October 2012
    Removed HSL support implementation from task list
    Will be added if many of you will request it

    Updated repo:
    Implemented chaining for all generic objects (that are available from the start and do not need requiring)

    Box2d Enhancements:
    Implemented merging the concept of body and sprite, making all body functions available to sprite and chaining them
    Also implemented that by changing position or rotation of sprite also moves or rotates the body (backwards interaction)
    Implemented local collisions for physics, basically a callback for collision of two specific sprite objects
  • bowerandybowerandy Guru
    edited October 2012
    @ar2rsawsenn, once again, this is some piece of work.

    I guess my only reservation is that it is so huge, it will need a lot of documenting if it is to truly make Gideros easier to use.

    I have a couple of points for now.

    1) I think the redefinition of "require" needs to be modified to return the module value:
    local _require = require
    require = function(name)
    	local answer=_require(name)
    	if name == "box2d" then
    		-- load box2d extensions
    		loadPhysicsExtension()
    		require = _require
    	end
    	return answer
    end
    2) Where should we put stuff that would normally go in init.lua? For example, my Hot Wax stuff has some definitions that need to be loaded before any other lua files. However, if I'm using GiderosInit then I no longer have this option without editing your file.

    Maybe we should have a GiderosInit.lua and then users just need to create their own init.lua to require it when they need to? This would be little more effort than dragging in the new init.lua as they have to now.

    best regards
  • ar2rsawseenar2rsawseen Maintainer
    edited October 2012
    @bowerandy
    1) Thank you for this I'll update it ASAP
    2) Thats a great point you raised here.
    Well it is huge for now. Once I'll add all features, I will work solely on optimizing it and minimizing the code.
    And of course there will be a documentation online and offline and comments in the code.
    About init.lua, well yes it should be in init.lua, because it is executed first that's understandable. To require GiderosInit in init.lua means it should be removed from Code execution (I actually hate when I need to mess with executions or dependencies in my project) or else I think it will be executed twice.
    So thats a really great question, one that I will need to think about more, but I'm open to suggestions (Maybe we can merge Gideros Init to include Wax implementation? :D ).
    On the other hand requiring inside init.lua would provide an advantage of easily enabling and disabling extensions. So this is something that needs to be thought about.

    It's just right now I'm really busy, just launched an update for Mashballs on Android and now submitting IOS version, and working on marketing plans.

    But let's ask others, if they are going to use it, how would they like to do it?
    • Manage their own init.lua file, mergin copying functions by themselves
    • Adding GiderosInit.lua to project, removing it from execution and requiring inside init.lua
    • Forcing @atilim to create specific case to load giderosinit.lua file similar to init.lua :)
    • Any other suggestion someone can offer
  • atilimatilim Maintainer
    edited October 2012
    At the code dependencies dialog (right click .lua file -> Code Dependencies...), you can make init.lua dependent to GiderosInit.lua or vice-versa. So that it's possible to execute first init.lua and second GiderosInit.lua or vice-versa.
  • atilimatilim Maintainer
    edited October 2012

    It's just right now I'm really busy, just launched an update for Mashballs on Android and now submitting IOS version, and working on marketing plans.
    good luck!!
  • bowerandybowerandy Guru
    edited October 2012
    @ar2rsawseen, sorry to trouble you at this busy time but I think there might be a problem with setAnchorPoint() on text fields. Try this:
    local text=TextField.new(TTFont.new("Tahoma.ttf", 30))
    text:setAnchorPoint(0.5, 0.5)
    text:setText("Welcome to GiderosInit")
    text:setPosition(384, 512)
    stage:addChild(text)	
    GTween.new(text, 2, {rotation=360}, {repeatCount=0})
    I would expect the anchor point to be the center of rotation as it is with Bitmaps. Actually, if you look at my BhHelpers file you'll see that I had a go at adding bhSetAnchorPoint() myself but I gave up. I found it too hard (sigh). I think this was one of the problems I came across.

    best regards
  • @bowerandy
    hehe, silly me, I think it's relatively easy to fix it, I need to move contents of setRotation method to set method, and call set from setRotation, as GTween only uses set method.

    Let me try this ;)
  • @ar2rsawseen, great!

    BTW, why call not this library something like GiderosCodingEasy or GCodingEasy, rather than GiderosInit? Sounds a bit more funky (and would also remind us all who put all this together).

    best regards

    Likes: paulocarrasco

    +1 -1 (+1 / -0 )Share on Facebook
  • Ok Updated repo,
    It now rotates almost around Anchor points :D
    Basically I can't understand if AnchorPoint is in incorrect position, or object is simply is changing it's x y position (it should change because of anchor point but it should be seamless)
    All in all I think it's a rounding problem, will need to look over the code and place math.round methods on position/etc settings ;)

    Likes: paulocarrasco

    +1 -1 (+1 / -0 )Share on Facebook
  • @bowerandy love the idea about name. Might as well use it ;)

    Likes: paulocarrasco

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.