Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
My feature suggestion for gideros — Gideros Forum

My feature suggestion for gideros

alexzhengalexzheng Guru
edited July 2012 in Suggestions & requests
I will update this thread as soon as I get some idea when using gideros.


First is about MovieClip
Keep an internal reference for an movie clip before it's completed and dereference it when completed. Two reasons for that: 1.We will not need to make a reference for a local movie clip and dereference it when it's completed just for preventing it from collectgarbage.
2. it become very Simple to add MovieClip.stopAll() if all the movie clips are referenced internally.

Second is about index position of child sprite
add function for modify the index position of child sprite, for example
Sprite:setIndex(index) --set the index position to index
Sprite:bringToTop() -- bring the sprite to the top of all children in its parent
Sprite:bringToBottom() -- bring the sprite to the bottom of all children in its parent
In some games,I may need to drag a sprite A and drop it on top of sprite B,but if the index of B is larger than A,currently I must remove A first then add A again to make sure A is on top of B.

Likes: fliego

+1 -1 (+1 / -0 )Share on Facebook
«13

Comments

  • And I just got another one

    Timer.delayedCall() return a handler for cancel it if needed.
  • alexzhengalexzheng Guru
    edited July 2012
    And another feature:
    Add an export library option in the export project dialog.
    Most all of time ,after export the whole project the first time and made some modification to the xcode project , I just check on the export assets only option in the export project dialog. However, the problem come out when gideros updated,most of my project still use the old libgideros.a.
  • petecpetec Member
    And I just got another one

    Timer.delayedCall() return a handler for cancel it if needed.
    +1 for that!
  • alexzhengalexzheng Guru
    edited July 2012
    And another feature:
    Add an export library option in the export project dialog.
    Most all of time ,after export the whole project the first time and made some modification to the xcode project , I just check on the export assets only option in the export project dialog. However, the problem come out when gideros updated,most of my project still use the old libgideros.a.
    After update the libgideros.a to the latest, I still got a black screen after return from
    leaderboard as before, and the application is still running
  • hi @atilim.

    The black screen showed frequently, not only return from leaderboard but also return from any other custom full views.

    Just pop up the leaderboard and leave it there, after a cup of tea and dismiss the leaderboard,the game view become black but the ad banner is still live.

    here is the screencast
    IMG_0859.PNG
    320 x 480 - 49K
  • hi @atilim.
    Can you take a look at this black screen bug when you get some time.
  • bowerandybowerandy Guru
    edited July 2012
    @alexzheng, with respect to bringToFront(/sendToBack/setIndex there is a partial reply here:

    http://www.giderosmobile.com/forum/discussion/comment/9038#Comment_9038

    I've just taken a look and it appears you can implement all three fairly easily. Just put the following in an extensions Lua file that is loaded by all your projects:
    function Sprite:bringToFront()
    	self:getParent():addChild(self)
    end
     
    function Sprite:sendToBack()
    	self:getParent():addChildAt(self, 0)
    end
     
    function Sprite:setIndex(index)
    	local parent=self:getParent()
    	if index<parent:getChildIndex(self) then
    		index=index-1
    	end
    	parent:addChildAt(self, index)
    end

    Likes: jack0088

    +1 -1 (+1 / -0 )Share on Facebook
  • alexzhengalexzheng Guru
    edited July 2012
    thanks @bowerandy
    Very nice,according to the documents

    Sprites can have only one parent. Therefore if you add a child object that already has a different sprite as a parent, the sprite is removed from the child list of the other sprite and then added to this sprite.


    Maybe even if you add the child object to the same parent,the child is removed from the parent first then add to the same parent again
  • alexzhengalexzheng Guru
    edited August 2012
    Although my suggetions were ingored,I still want to share some of my idea for gideros.
    One more idea:

    After exporting the project,the first thing you have to do is makeing different size of icons to the project.
    Currently,I have more than 10 games,and I did some modification to the exported projects. So when I need to update the whole project(not only the asset),it's very time consuming, and I plan to modify the template project before export. However the icon can not be added aumatically. I think it would be nice to add a Icon.png(maybe 512 *512) to the gideros project and when export the project for ios or android, it was converted to Icon.png ,Icon-72.png, Icon@2x and so on for the exported project.

    Likes: ar2rsawseen

    +1 -1 (+1 / -0 )Share on Facebook
  • atilimatilim Maintainer
    Now Timer.delayedCall returns a Timer object so that either you can ignore the returned value or stop it whenever you want:
      local timer = Timer.delayedCall(1000, func)
      -- 
      timer:stop()
  • atilimatilim Maintainer
    On the other hand, I disagree about keeping internal references to running MovieClips. In this case, looping MovieClips won't be collected ever (and consume memory and CPU) even if they are no longer accessible.
  • Now Timer.delayedCall returns a Timer object so that either you can ignore the returned value or stop it whenever you want:
      local timer = Timer.delayedCall(1000, func)
      -- 
      timer:stop()
    thanks.
  • When will the MovieClips be collected currently?
    In my test,it may be collected before or after it completed,so I must make a reference to it myself.

  • atilimatilim Maintainer
    edited August 2012
    If a MovieClip object is not accessible, then it's collected at the next GC cycle (even if it's running).
    local mc = MovieClip.new(....)
    mc:addEventListener(Event.COMPLETE, my_func)
    ---
    mc = nil
    collectgarbage()
    here my_func will not be called because mc is collected.



    But this is not the case for Timer and UrlLoader objects. If a Timer or a UrlLoader object is already running, it's not collected.
    local timer = Timer.new(1000, 1)
    timer:addEventListener(Event.TIMER, my_func)
    timer:start()
    ---
    timer = nil
    collectgarbage()
    here my_func will be called after 1000 miliseconds. Because Timer objects are not collected if they are already running. After Timer object stops then it's eligible for GC.
  • @atilim
    so using Timer.pauseAll() will not make any unaccessible Timer objects eligible for GC? we must use Timer.stopAll()?
    have fun with our games~
    http://www.nightspade.com
  • atilimatilim Maintainer
    Also
    local mc = MovieClip.new(....)
    mc:addEventListener(Event.COMPLETE, my_func)
    stage:addChild(mc)
    ---
    mc = nil
    collectgarbage()
    here mc is not collected and my_func will be called because mc is added to the stage.
  • alexzhengalexzheng Guru
    edited August 2012
    what I'm afraid of is the my_func will not be called in the following code

    local mc = MovieClip(....)
    mc:addEventListener(Event.COMPLETE, my_func)

    So I always make a reference to mc somewhere else,is it necessary?
  • atilimatilim Maintainer
    edited August 2012
    Also
    Timer.pauseAll()
    local timer = Timer.new(1000, 1)
    timer:addEventListener(Event.TIMER, my_func)
    timer:start()
    Here my_func won't be called until Timer.resumeAll() is called. Timer.pauseAll() pauses the internal clock that's used by all Timer objects.


    But
    Timer.stopAll()
    local timer = Timer.new(1000, 1)
    timer:addEventListener(Event.TIMER, my_func)
    timer:start()
    Here my_func will be called after 1000 miliseconds.
  • atilimatilim Maintainer
    edited August 2012
    @alexzheng but why do you create a MovieClip object and don't add to the stage after creating?
  • alexzhengalexzheng Guru
    edited August 2012
    Also
    Timer.pauseAll()
    Timer.new(1000, 1)
    timer:addEventListener(Event.TIMER, my_func)
    timer:start()
    Here my_func won't be called until Timer.resumeAll() is called. Timer.pauseAll() pauses the internal clock that's used by all Timer objects.


    But
    Timer.stopAll()
    Timer.new(1000, 1)
    timer:addEventListener(Event.TIMER, my_func)
    timer:start()
    Here my_func will be called after 1000 miliseconds.
    Then after Timer.pauseAll(),will the Event.ENTER_FRAME still dipatched, or this event is not triggered by the internal clock.
  • atilimatilim Maintainer
    Yes, Event.ENTER_FRAME event is independent of internal timer clock.
  • @alexzheng but why do you create a MovieClip object and don't add to the stage after creating?
    I'm not sure what's the right way to use MovieClip, I just add the sprite to the stage and create a MovieClip to make an animation.
  • atilimatilim Maintainer
    edited August 2012
    I think I finally understand you now.

    You should add the MovieClip object to the stage, not the sprites that MovieClip object is made of.
  • Yes, Event.ENTER_FRAME event is independent of internal timer clock.
    maybe add a handy function to pause and resume all ENTER_FRAME event will be better,
    I always check a pause flag in each ENTER_FRAME handler.

  • atilimatilim Maintainer
    edited August 2012
    For example here is a sample:
    local sprite1 = Sprite.new()
    local sprite2 = Sprite.new()
    local sprite3 = Sprite.new()
     
    local mc = MovieClip.new(bla bla sprite1 bla bla sprite2 bla bla sprite3 bla bla)
    mc:addEventListener(Event.COMPLETE, function(mc) mc:removeFromParent() end, mc)
    stage:addChild(mc)
  • in this way?

    local sprite = Sprite.new()
    local mc = MovieClip.new{
    {1, 100, sprite, {x = {0, 200, "linear"}}}
    }
    stage:addChild(mc)
  • atilimatilim Maintainer
    edited August 2012

    maybe add a handy function to pause and resume all ENTER_FRAME event will be better,
    I always check a pause flag in each ENTER_FRAME handler.
    Yes that would come in handy. Implementing pausing in a game is usually hard.
  • atilimatilim Maintainer
    edited August 2012
    in this way?

    local sprite = Sprite.new()
    local mc = MovieClip.new{
    {1, 100, sprite, {x = {0, 200, "linear"}}}
    }
    stage:addChild(mc)
    exactly.
  • alexzhengalexzheng Guru
    edited August 2012
    For example here is a sample:
    local sprite1 = Sprite.new(...)
    local sprite2 = Sprite.new(...)
    local sprite3 = Sprite.new(...)
     
    local mc = MovieClip.new(... sprite1 ... sprite2 ... sprite3 ...)
    mc:addEventListener(Event.COMPLETE, function(mc) mc:removeFromParent() end, mc)
    stage:addChild(mc)
    Then after Event.COMPLETE, sprite1 sprite2 sprite3 will be remove from stage?

    My common situation, the sprite is always on the stage, and I need to make different animation to the sprite, so I just add the sprite to the stage not the MovieClip.

Sign In or Register to comment.