Forums

OverviewFelgo 2 Support (Qt 5) › Spawning enemies faster over time

Tagged: , ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15714

    Isak

    Hello,

    I need some advice on how to implement faster spawning of enemies. i have the following Timer that spawns enemies:

    
            Timer {
              id: timerSpawningEnemies
              interval: 2000
              running: gameState == "play" ? true : false
              repeat: true
              onTriggered: {
    
                  enemyId = Math.floor(Math.random() * (3 - 1 + 1) + 1)
                  console.log(enemyId)
    
    
                  if (enemyId === 1) {
                      entityManager.createEntityFromUrl(Qt.resolvedUrl("Ufo.qml"));
    
                  }
    
                  else if (enemyId === 2) {
    
                      entityManager.createEntityFromUrl(Qt.resolvedUrl("Asteroid.qml"));
    
                  }
    
                  else if (enemyId === 3) {
    
                      entityManager.createEntityFromUrl(Qt.resolvedUrl("Bomb.qml"));
    
                  }
    
    
    
    
    
              }
    
            }

    And i want to be able over time speed up how fast i spawn them, and i am thinking about some property binding on the interval? But don’t really know how to do it. I have a points property, the player gets on point for every time they avoided an enemy so i thinking using that to increase the spawningspeed like every 20 points the spawning gets faster? Can i do this with some property binding on the interval or should i use an function that handles this?

    Thanks

    /Isak

    #15731

    Günther
    Felgo Team

    Of course the timer interval is what you need to decrease over time to spawn the entities faster.
    For that, it doesn’t matter if you use a function or a property binding, as long as the solution works.

    Best,
    Günther

     

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support