Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Showing curvey dashed lines when travelling across a map? — Gideros Forum

Showing curvey dashed lines when travelling across a map?

I have a main game map, where there are points where the levels are at. Standard stuff. So I want to animate dashed lines extending to the next level point that would be invisible until the level is activated.

Is there a amazing/lazy way of doing this, maybe with Path or something? I'd rather have very curvy/silly lines so masks wouldn't be good.

Comments

  • olegoleg Member
    edited December 2017
    try it Bezier:

    http://devmag.org.za/2011/04/05/bzier-curves-a-tutorial/

    or so?



    -
    -создаем масив точек:
    pike={
            5,4,
            107,56,
            99,108,
            42,123,
            28,84,
            45,38,
            112,21,
            165,41,
            175,110,
            141,182,
            48,236,
            30,232,
            41,175,
            105,156,
            166,174,
            184,215,
            180,254,
            148,293,
            139,311,
            134,329
    }
    --функция движения от точки к точке  с заданной скоростью
    function speed_move2(sprite,x2,y2,speed)
     
     
     
            x1, y1 = sprite:getPosition()
     
            local d=math.sqrt(math.abs(x1-x2)^2+math.abs(y1-y2)^2)  --довж гіпотенузи
     
     
            speed=(d/speed)*1000
     
     
            speed=speed/1000*60  --60fps
     
     
            sprite.move = MovieClip.new{
                            {1, speed, sprite, {x = {x1, x2, "inBack"},y = {y1, y2, "inBack"}}}  -- проиграть с 1 до 100кадра с движением по оси  Х от 0 до 200
                    }
            sprite.move:gotoAndPlay(1)
            sprite.move:addEventListener(Event.COMPLETE ,function()runpath(sprite) end )
    end
    enemy1 = Core.class(Sprite)
     
    function enemy1:init(x,y,path,speed)
     
     
            self.frame={}
            self.frame[1] = Bitmap.new(Texture.new("controllers/enemy1/krovosisi0001.png"))
            self.frame[2] = Bitmap.new(Texture.new("controllers/enemy1/krovosisi0002.png"))
     
     
     
            self.anim = MovieClip.new{
                    {1, 3, self.frame[1]},
                    {4, 7, self.frame[2]}
     
            }
            self.anim:setGotoAction(7, 1) 
            self.anim:gotoAndPlay(1)
            ----------------------------------------------------
     
            self:setPosition(x,y)
            self.x=x
            self.y=y
            self.path=path
            self.speed=speed
            self.step=3
            self:addChild(self.anim)
     
     
            stage:addChild(self)
     
            runpath(self)
     
    end
     
    function runpath(self)
     
     
            if self.step+1==#self.path then 
                    self.step=3
                    self.x=self:getX()
                    self.y=self:getY()
            else
                    self.step=self.step+2
            end
     
     
             self.x2=self.x+self.path[self.step]-self.path[1]  
             self.y2=self.y+self.path[self.step+1]-self.path[2]
     
            speed_move2(self,self.x2,self.y2,self.speed)
     
    end
    enemy1.new(100,100,pike,50)
    22.JPG
    237 x 321 - 33K
    22.JPG 33.4K
    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
    +1 -1 (+2 / -0 )Share on Facebook
  • Thanks for that... it seems like it would work with Bezier/quad curves, but the issue there would be drawing them as dashes I think.

    Brute force multi image is an option, but it's inflexible.
Sign In or Register to comment.