Search the Community

Showing results for tags 'delay'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

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

Found 17 results

  1. Camera following with delay

    Hi guys, First excuse me for my english. I want the camera to follow a sprite and I set the position of this sprite every frame. function create(){ this.player = new Player(this.game); this.playerController = new PlayerController(this.game, this.player); this.cameraTarget = this.game.add.sprite(this.player.x, this.player.y, "cameraTarget"); this.cameraTarget.anchor.setTo(0.5, 0.5); this.camera.follow(this.cameraTarget); } function update(){ this.playerController.move(); this.cameraTarget.x = this.player.x; this.cameraTarget.y = this.player.y; } This work but the camera have a small delay, here is some picture of this (red = player, yellow = cameraTarget). Not moving : Moving to the right : Moving to the left : You can see the delay of the camera with the yellow box's offset (Trust me the yellow box is always centered on my screen). The stranger thing is when I set the follow of the camera on the player it work well, no delay. Don't tell me to set the follow of the camera on the player plz, I need this cameraTarget for later calculations. Here is the gitHub if you want the code : https://github.com/JohnyBro/Platformer If someone can help me with this it will be appreciated.
  2. Hi, Looking around for a lazy-loading mesh example. There is assetManager and sceneLoader, with ImportMesh, .append() and .load() variations. All good there. : ) Question: Which way is best to delay-load (lazy-load) 3D meshes? The original hope was for AssetManager to be able to delay-load. Does it? - Looking for something like runTask, after init, but then found ._runTask, so maybe delay not possible. Did I miss it? Idk. : ) 2) Next, sceneLoader.append, can it lazy-load? Couldn't find example.... 3) ImportMesh, my previous favorite way, but recently standardized around AssetManager, and hesitant to switch. etc. Which is best to lazy-load? Thanks,
  3. The documentation for sprite animation is a bit out of date and a new method setAnimationSpeed(speed) or setAnimationSpeed(identifier, speed) should be added. I have a sprite and an animation this._super(me.Sprite, 'init', [339, 480, settings]); this.addAnimation('normal', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],100); this.setCurrentAnimation('normal'); This animates at a delay of 100 ms. I can change the animation delay by adding another parameter to the addAnimation method. I could not change the delay afterwards with the solutions I found. I have seen this answer: https://groups.google.com/forum/#!topic/melonjs/mk6mVcMoVKo but it is no longer relevant. this.anim.normal.animationspeed isn't a part of melonjs anymore and changing the other animationspeed settings doesn't have any effect. This is I think, because of a change from a 'global' animation delay to a frame-based animation delay. The new method for changing the speed of an animation should now be: setAnimationSpeed: function(identifier, speed) { for (var i = this.anim[identifier].frames.length - 1; i >= 0; i--) { this.anim[identifier].frames[i].delay = speed; } } There should be a note on the sprite and/or renderable pages about the animation speed able to be individually set on a per-frame basis. It could be useful for example if some character is looking to the left and then turning quickly to the right the frame set wouldn't have to look like this: [0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[1],[2],[3],[4],[5],[5],[5],[5],[5],[5],[5],[5] and could just have a long delay on the 0 and 5 frames. Every X.0.0 version should result in a new version of the wiki and documentation with the changes you're making. Relevant changes to each could be made to affected pages after.
  4. Generate items with delay

    Hi all, I'm trying to generate items randomly. For the moment it's ok, but I would like to add a little delay from every items. For exemple, I would like to find a way to generate them every 2scd. My code below : In the create() : emails = level2.add.group(); emails.enableBody = true; In update() function createEmails(mail) { var mail = emails.create(level2.world.randomX, 0, 'email'); mail.width = 50; mail.height = 40; // mail.name = 'mail' + x.toString() + y.toString(); // mail.checkWorldBounds = true; mail.events.onOutOfBounds.add(mailOut, this); var numY = Math.random() * 500 + 200; // Get a number between 200 and 500; mail.body.velocity.y = numY; var numX = Math.floor(Math.random() * 99) + 1; ; numX *= Math.floor(Math.random() * 2) == 1 ? 1 : -1; mail.body.velocity.x = numX; } function startGame(mail) { if (score >= 1000) { emails.destroy() } else if (scoreEnemy >= 1000) { emails.destroy() } else { createEmails(); } } Thanks by advance !
  5. Hi everyone, I am currently working on a 3D scene that using VRDeviceOrientationFreeCamera and DeviceOrientationCamera, I experienced serious delay on both cameras. Based on what I have seen so far, it takes at least half a second for the camera to start rotate after I rotate my device. I try on other demo scenes with vr features enabled on babylonjs.com, there are also significant delay on the camera. Is this issue solvable by tweaking around the camera input or is it something we need to bear with if using the babylon default vr camera?
  6. I want to loop a work a number of times and between each loop will be an interval (like setInterval in Javascript). I have used tween to make loops but don't know how to make intervals between them. You could use the example here to try: http://phaser.io/examples/v2/tweens/tween-loop-event#g Hope you could help me. Thank you very much!
  7. Hi guys, I'm struggling with this problem for a couple of days now. When I touch an element in my game I'm playing a sound effect. I want this effect to play instantly when i touch this element. The problem is there is a small delay (like 200ms) when i touch this element on my phone (Samsung Galaxy S4). I tried everything, SoundJS, Howler, custom Web Audio API code, but the problem persist. Im building my game with IntelXDK and Crosswalk. The problem only occurs on mobile, on desktop there is no delay. Could anyone help me with this problem or has some info? Or maybe could some other HTML-5 mobile developer give me some help with a good solution to use sounds in my game. Thanks!
  8. Hello, I'm trying to animate clones of an object but with a delay between animation. You can find a test here : http://www.babylonjs-playground.com/#ACLYP#1 But as you can see, the delay between animation is not constant, after the first loop, all animation are not sync, how can i keep the same delay after all the loop ? Maybe it's not the right way of doing this, can someone help me with this ? In this configuration I can keep the delay between animation but some of them never end : http://www.babylonjs-playground.com/#ACLYP#2 Thanks !
  9. Got a game that plays sound as it should do on desktop, and iOS is pretty good too. However Chrome on Android is proving difficult. (Been testing primarily with a Galaxy S6 but the problem is common across a range of devices) The issue I am experiencing is that when the first sound tries to play there is a delay in the region of half to a whole minute before it eventually makes a noise. After the first sound plays the rest seem to work fine. We have a screen that needs user interaction to get through that is supposed to in the process unlock sound but for the purposes of this I've enabled the chrome://flags/#disable-gesture-requirement-for-media-playback so that it doesn't have any impact on the this issue. I can confirm that if I get the game to play a sound after it finishes the initial load with this flag enabled it will do so without user interaction, eventually - there is still the long delay. The game is using webAudio and sound spriting. All the sounds are added to phaser and spriting maps set up before any attempt to play sound is made. The sound file is being successfully loaded and is in ogg format to minimise decode time. If the game is left alone for a while before trying to play a sound the sound plays without delay. Does anyone recognise this problem? Any advice at trying to resolve it would be greatly appreciated.
  10. Adding sprite group over time

    Hi All, phaser newb, novice js I'm trying to build a little christmas game, sort donkey kong-ish, with some gifts that go along some conveyer belts into santa's bag (attached a pic). I'm creating a group of gift sprites behind the pipe in the top right. I want to add gravity to each one but over time so they stream out of the pipe in sequence. Would you do this in the update: function() . Is there a way to create the sprites over time and add them to the group? Can your add a delay somehow? cheers for any advice/help in advance here's my js for the group buildGifts: function(){ this.giftgroup = this.add.group(); this.giftgroup.enableBody = true; for(var i=0; i<this.totalGifts; i++){ var g = this.giftgroup.create(1000, 80, 'blueGift', 0000); g.anchor.setTo(0.5,0.5); g.body.moves = true; g.animations.add('gifted', Phaser.Animation.generateFrameNames('gift', 0, 0, '', 4), 30, true); this.game.physics.arcade.enable(g); g.body.bounce.y = 0.2; // g.body.gravity.y = 1500; g.body.velocity.x = 0; g.inputEnabled = true; g.events.onInputDown.add(this.destroyGift, this); }
  11. delay between animations

    hi buddies, again me, i just wanna ask u all if in phaser we can have a delay between animations frames? any example? i just wanna introduce a little delay between each frame and then when the animation is complete lauch an event. thanks in advance.
  12. Remove object in group after delay?

    I already know how to destroy a group object when it collides with something else. However, I can't seem to find a way to delay the destruction of the object after the collision. The following code works for instantly destroying the otherThing in the otherThings group that the thing object overlaps: game.physics.arcade.overlap(thing, otherThings, removeOtherThing, null, this);function removeOtherThing (thing, otherThing) { otherThing.destroy();}What I want to do is delay the destruction of the otherThing object by an arbitrary amount. I can't seem to find a way that works, though, with the methods I've tried so far returning errors. Help would be appreciated!
  13. For example, in a shooting game. That when you throw a shot, you may have to wait a while to be able to pull another shot. Any ideas?
  14. Here is a blank template for my game. As you can see - the transition between the states of the game begins with the shutters Theoretically, after the divergence of shutters next screen should appear IMMEDIATELY!But change screens is delayed.How to remove this delay? source code - http://pastebin.com/vHN6jcY4
  15. Hello, everybody. I've been using Phaser for the last couple of weeks and I had almost no problem until I reached the point where I need to modify the sound graph on the web audio API implementation inside the engine. I saw Sound.externalNode but I have no idea of how to connect the nodes and how to access them through Sound or SoundManager. I just want to create delay and feedback nodes and connect them somehow using the Sound class. Is this possible? Is there any example? Is the node structure (the graph) of how SoundManager and Sound are connected anywhere in the docs? I can't find it Thanks a lot in advance and keep on with this awesome software!
  16. How can I add a delay inside the update loop?

    Let's say I have a variable "assets" that is an object and contains several sprites. Inside the update loop, I check the position of each sprite by iterating through the object. If a condition is true (the sprite is outside the game bounds), I want to wait a random amount of milliseconds and then give that sprite a new position without the need of destroying it and creating a new one. I want to use the same amount of sprites and continue re-spawning them until another condition is met (out of lives or whatever). I tried using setTimeout() but it does not work inside the loop. Furthermore, I'm having problems figuring out how to "freeze" one sprite while the rest keep moving (that means I cant pause the update loop, although I don't even know if that's possible). Please keep in mind that this is a mobile game and performance is important. Is it really worth the effort? Should I just kill them and spawn new ones? Thanks for reading.
  17. Delay enemy actions

    I have a group of enemies that I loop through and perform various actions with, in my update loop. Basically it checks if each enemy in the group is either at a wall and should turn back, or at a ledge of a platform, and should either 1) turn back, 2) jump, 3) fall off the ledge. The problem I'm having is that nothing is working properly as the update of course happens 60 times a second, and it rapidly checks the conditions and makes decisions. My attempted solution is to attach a timer to each of the enemies in the group, and check if the timer is expired before attempting these actions. Then in the actions function I start the timer, which should run for a couple of seconds. The theory being that after taking an action, it should delay attempting again (per enemy) and by that time the enemy has moved on and the condition (at the ledge, etc.) has passed. I can't figure out a) if this possible and how to do it in Phaser. Since the timer object seems to require a callback, I thought I would make a callback function set/change a flag on the enemy that tracked if it could perform the action or not. I have code like this: Enemy creation: spawnSlime: function() { // create a new slime var yellowSlime = this.slimes.create(760 + Math.random() * 100, 70 + Math.random() * 60, 'medSlime'); yellowSlime.anchor.setTo(0.5, 0.5); yellowSlime.animations.add('slime-walk', [0, 1, 2, 4, 3, 2, 1, 0], 6, true); this.physics.arcade.enable(yellowSlime); this.physics.arcade.collide(yellowSlime, this.layer_world); yellowSlime.body.gravity.y = this.GRAVITY; yellowSlime.body.collideWorldBounds = true; yellowSlime.play('slime-walk'); yellowSlime.speed = -(Math.random() * 40); // create a timer for each slime yellowSlime.actionTimer = this.game.time.create(false); yellowSlime.actionTimer.loop(2000, function(){yellowSlime.actionReady=true;}, this); // ready for actions, which the timer will be used to provide a pause between actions yellowSlime.actionReady = true; yellowSlime.body.velocity.x = yellowSlime.speed; // console.log(yellowSlime.body.velocity.x); yellowSlime.slimeID = this.slimeCounter += 1; console.log('new slime ID: '+yellowSlime.slimeID) },As you can see I attempt to attach a timer to the slime there, and a callback anonymous function which changes the actionReady state. Here is the code for the slime actions: // slime actions this.slimes.forEach(function(thisSlime){ // collide all slimes with world this.physics.arcade.collide(thisSlime, this.layer_world); this.physics.arcade.overlap(thisSlime, this.lavas, this.lavaDamage, null, this); // Slime meets obstacle or ledge.. either turn back, fall off ledge, or jump console.log('actionReady: '+thisSlime.actionReady); if (thisSlime.actionReady) { if (thisSlime.body.blocked.down) { // slime is on the ground // don't check this slime again for 2 seconds thisSlime.actionReady = false; console.log('about to start timer'); thisSlime.actionTimer.start(); if (thisSlime.body.blocked.left) { // go right thisSlime.body.velocity.x = thisSlime.speed; } else if (thisSlime.body.blocked.right) { // go left thisSlime.body.velocity.x = -thisSlime.speed; } else if (this.tileGet(thisSlime, this.layer_world, 'right') == 0) { // slime on ledge, drops off to the right if ((Math.random() * 3) > 2) { // 1 in 3 chance to jump, otherwise fall off ledge // make slime jump thisSlime.body.velocity.y += 60; console.log('slime'+thisSlime.slimeID+' is jumping'); } else { thisSlime.body.velocity.x = -thisSlime.speed; console.log('slime'+thisSlime.slimeID+' is going back left'); } } else if (this.tileGet(thisSlime, this.layer_world, 'left') == 0) { // slime on ledge, drops off to the left if ((Math.random() * 3) > 2) { // 1 in 3 chance to jump, otherwise fall off ledge // make slime jump thisSlime.body.velocity.y += 60; console.log('slime'+thisSlime.slimeID+' is jumping'); } else { thisSlime.body.velocity.x = thisSlime.speed; console.log('slime'+thisSlime.slimeID+' is going back right'); } } else { // no conditions met, keep actionReady as true thisSlime.actionReady = true; } } }So this function checks the actionReady boolean, and then attempts the actions by first checking the conditions (at a wall or ledge). I have a tileGet function that checks what tile is beyond the ledge, which works. If at a wall it just turns around. However if at a ledge, it makes a random choice for turn back | jump | continue and fall off ledge. As mentioned the timer starting is supposed to change the condition for a couple of seconds so that the slime is not checking/making decision rapidly, canceling them out. I'm not getting an error here, but the slimes are just always falling off the ledge, and the condition seems to be rapidly checked, as if the timer isnt working, as evidenced by my console output: https://www.dropbox.com/s/minssx6l754g03k/Screenshot%202014-05-10%2022.23.36.png When I tried a function instead of an anonymous function, I would get an error. The call: yellowSlime.actionTimer.loop(2000, this.readyForAction(yellowSlime), this);and the function: readyForAction: function(entity) { entity.actionReady = true; },Any help would be appreciated. Keep in mind that I'm not an expert in javascript, I'm still learning, so there may well be js problems - and I'm not quite sure if/how the Phaser timer function can be used for this. thanks Chris