Search the Community

Showing results for tags 'interval'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 2 results

  1. BrunoHautenfaust

    Generate objects at dynamic intervals

    Hi! I've been at this for hours. I'm trying to make an endless runner game. The idea is that the player is standing still, but the stage is moving, giving the illusion that the player is moving. I want to generate some obstacles at a random distance from each other. Like so: _____@_____@__@________@__ At some point maybe I'd like to set the minimum space between each obstacle but I'm far from there. Here's what I got for now: create() { spawn = 1000; timer = game.time.events.loop(spawn, this.addObstacle, this);},update() { this.updateTimer();},updateTimer: function() { random = Math.floor((Math.random() * 500) + 100); spawn = 1000; timer = game.time.events.loop(spawn, this.addObstacle, this); }....I'm getting Uncaught TypeError: Cannot read property 'reset' of null because I have 10 obstacles and they all pop up on screen at the same time. And there's no 'dead' obstacle for getFirstDead(). Another thing I tried was this: update() { random = Math.floor((Math.random() * 500) + 100); // I think this causes lags and it doesn't feel right this.updateTimer(random);},updateTimer: function(r) { timer.delay(r);}....But here timer.delay is not a function. So far I can spawn obstacles at even intervals with just this line: timer = game.time.events.loop(<Integer>, this.addObstacle, this); P.S. And what is 'this' in this.updateTimer()? I thought it was 'game'. I see it constantly in the API. Guess the creators know pretty darn well its usage.
  2. sinanqd10

    why cannot call function in button?

    var diff, increase_end_angle = 0, start_angle = 1.5 * Math.PI,end_angle = 2 * Math.PI, startTime = (new Date()).getTime(), circleTimer; create: function { button = this.game.add.button(0,0,'btnNext', this.start,this); }, circleTimer: function () { var graphics = game.add.graphics(0, 0); diff = (new Date()).getTime() - startTime; diff = diff / 60000; //60000ms = 60s increase_end_angle = start_angle + end_angle * diff + reduce; graphics = game.add.bitmapData(80,80); graphics.context.fillStyle = '#D24545'; graphics.context.beginPath(); graphics.context.arc(x,y,radius,start_angle,increase_end_angle,false); graphics.context.lineTo(x,y); graphics.context.fill(); graphics.context.closePath(); game.add.image(13, 8, graphics); }, start: function () { circleTimer = setInterval(this.circleTimer, 200); }, update: function() { if(diff > 1 ) { clearInterval(circleTimer); } },