Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
0
Members

Wait function

A topic by Aniworks created Oct 09, 2020 Views: 334 Replies: 5
Viewing posts 1 to 4
(+1)

So, how do i make superpowers wait? Simple as that. I just wanna make it so that the game drops a platform using gravity, waits a few seconds, and then bring the platform back to it's original position, and then finally lock it. What function can i use for the wait function?

lucky you,  i just connect myself. Here what i know:

Sup.setTimeout(1000ms,Nameofthefunction) // Wait and then call a function 
Sup.setInterval(1000ms,Nameofthefunction) // Wait and then call a function every 1000ms => use clearIntervall for end it (for timeout too)

And here a tips :

Use a local funtion, like that you can call it while the var it use are not deletes

function (Enemie: Actor[])
{ let idE = 0
  function KillEnemie() // the local one
  { Actor[idE].destroy()
   idE++
   Sup.setTimeout(1000ms,KillEnemie)
  } 
}

 with love, me.

Hey, for some reason, it's not resetting the platform at all! Here's the code, lemme know if i used it wrong.

    if (this.actor.arcadeBody2D.getTouches().top)
    {
        this.actor.arcadeBody2D.setCustomGravityY(-0.01)
        Sup.setTimeout(1000, returnPlatform)
        
    }
  function returnPlatform()
  {
    this.actor.arcadeBody2D.setCustomGravityY(0)
    this.actor.setPosition(this.pos)
    Sup.clearTimeout(0)
  }

help

Hey So the platform start to go down and stop ? What is the variable pos ?

With your code the platform will go downward and after 1 second stop to go downward and teleport to ‘this.pos’

that's what i intended but it didn't work