Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Collision with gtween delay - Gideros Forum

Collision with gtween delay

Hello,

I am happily and steadily progressing in my project. My last addition is a laser effect. The animation works this way: there is a wind up charge, then the laser itself, and finally some remaining particles. The animation is handled by various gtweens with delays to appear more or so after each other.

I am currently investigating ways to handle collisions. The problem is the laser is added to stage and appears with a delay. This is why the collision is validated before the laser appears. My last idea is to use:
if laserEffect:getAlpha() > whateverValue then testCollision() end
But I wonder if you guys ran in similar problems, and what strategy did you use?

Bonus: the effect itself.



Likes: MoKaLux

ezgif.com-crop.gif
345 x 154 - 1M
+1 -1 (+1 / -0 ) Share on Facebook

Comments

  • MoKaLuxMoKaLux Member
    edited July 2
    that's a nice effect indeed :) Have you tried:
    --adding event on animaton complete
    tween:addEventListener("complete", function()
        stage:removeChild(sprite)
        sprite = nil
    end)
    http://giderosmobile.com/tools/gtween
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • DafbDafb Member
    Hi,

    It seems my explanation was bad.

    I have no problem to remove the sprite. In fact I already use this code snippet for each element of this animation.

    The laser effect last 1.6 sec. And starts to appear 1.4 sec after the start of the animation.
    local tw5 = GTween.new(laserEffect, 1.2, {scaleX = 1, scaleY=1, alpha = 1}, {dispatchEvents = true, delay = 1.4, ease = easing.inQuintic})
     
    	tw5:addEventListener("complete", function()
    		afterRBigShoot() -- the after effect particles
    	end)
     
    	local tw6 = GTween.new(laserEffect, 0.4, {alpha = 0}, {dispatchEvents = true, delay = 2.6, ease = easing.linear})
     
    	tw6:addEventListener("complete", function()		
    		laserEffect:removeFromParent()
    	end)

    My concern is the best way to handle collision, knowing the sprite exists on stage before appearing on screen.
    I plan to use the sprite's alpha as a landmark (like mentioned in the OP) but I wonder if there are better ways to achieve this.



  • MoKaLuxMoKaLux Member
    yes sorry, my example was bad! I was more pointing to event complete (not the code inside it :) )
    Can't you test the collisions here?
    tw6:addEventListener("complete", function()
    	testCollision()
    	laserEffect:removeFromParent()
    end)
    Otherwise go the alpha way :)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • DafbDafb Member
    I went the alpha way. I am rather happy with the result.


    Likes: MoKaLux

    ezgif.com-crop(1).gif
    300 x 191 - 687K
    +1 -1 (+1 / -0 ) Share on Facebook
  • MoKaLuxMoKaLux Member
    pretty neat <3
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
Sign In or Register to comment.