Search the Community

Showing results for tags 'loop'.



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.js
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 46 results

  1. Interactive Video

    Hello everbody, I am new to this Forum. So please forgive me if I posted in the wrong thread. I am developing an Interactive visual novel made out of videos and video loops. Build up: - play video, go to loop; - choose dialog in loop; - play video, then go to action loop; - play mini game in action loop; - if won, repeat same process in different level, or game over. There are two things that I am struggling with: 1. How do I play an loop, after an video has been played? 2. I want to add an button during the loop, that will switch to an different video, depending on if it has been clicked fast enough in an certain time or not. I would be grateful for tipps. Thank you in advance!
  2. Hey all! I add a music track that I want to loop using this code: music = new Phaser.Sound(game, "music", 1, true); It loops correctly everywhere except on IE. Has anyone has this issue? Is the work-around to have an event fire on sound complete?
  3. Hey guys... I got yet another one... I am currently using an animation to control a curve... List call that animPosition... I encode root transform positions into the animation and the animation updates the animPosition.xyz from the BabylonAnimationKey... I use this to move the character... works great except my logic for when the animation loops (even with relative cycle mode)... Basically if the animation controlling the animPosition rotates the chaterter 0 to 90 degrees... when the animation loops the values are the same as before it just loops to when replayed it SNAPS back to 0 and goes from 0 to 90... again... What I need is to offset so that when the animation loops a second time this values in the animation 'Contribute' to the move of the character movement so when looping that animation with the sample numbers again a second time will make go from 90 - 180 and so on... so that values coming from the root motion accumulated (I guess): My animation state machine exposes that 'animated animPosition' as rootPosition and calculates the delta from the lastPostion... and it is exposed as: getDeltaPosition... that little bit off delta position is then use to move the character... _chacter.move() really call physicsImposter.setLinearVelocity anyways this is how I am taking the 'delta from the last position and using that as movement: if (this._animator != null) { var deltaTime:number = this.manager.deltaTime; var deltaPosition:BABYLON.Vector3 = this._animator.getDeltaPosition(); var rootPosition:BABYLON.Vector3 = this._animator.getRootPosition(); if (this._character != null) { this._inputVelocity.x = (deltaPosition.x * this.moveSpeed) / deltaTime; this._inputVelocity.y = 0.0; this._inputVelocity.z = (deltaPosition.z * this.moveSpeed) / deltaTime; var jumped:boolean = (this.manager.getKeyInput(this.keyboardJump) || this.manager.getButtonInput(this.buttonJump)); if (jumped === true) this._inputVelocity.y = this.jumpForce; this._character.move(this._inputVelocity, jumped); } } that moves everything great UNTIL the animation loop that resets the main animPosition (that delta is calculated from) to the values in the animation at starting frame... lets say for simple sake that is facing forward with no rotation.. call it 0... when the animation stops its at 90... the loop reset back to zero INSTEAD of continuing to turn to 180 (which is what I want) I know that a mouth full But if can figure this last part out... I will have root motion working for BabylonJS... Note: If anybody wants to help with issue (Animation State) or any of the other small issues I have outstanding... LET ME KNOW... I will send you a copy of the BabylonJS Toolkit Version 3.1 Beta and we can work together... I would love to be able to work with (and actually talk to) someone... We can GOTOMeeting and show each other code pieces and work on it together.... Outstanding Issues: - Animation System (including Blend Trees if can be done in BabylonJS) - Terrain System... Need to be able to use a Texture Atlas in GLSL Shader... right now the only way I know is to use 'fract' call... but that LEAVES EDGE SEEMS - LDR Skyboxes - you can't really use a HDR for the whole sky... (maybe for just HDR reflections which should be a MUCH smaller scaled down version of a full panorama HDR file)... So I created a HDR to LDR Tone Mapping Tool... To use it I need a babylonLDRCubeTexture.ts to be create that work like HDRCubeTexture EXPECT use the ALREDY encoded LDR Tone Mapped pixels as a JPG or PNG. Particle System - Fine tune my ShurikenParticleSystem class I created to give a Shurken time based particle system ike the used in Unity... I got everything going except some 'Update-Over-Time' functionally I need to give additional 'Velocity' to the 'AGED' particle over time... NOT just adjust the 'EMITTER POWER' which starts the particle on it way... but use a curve to control the velocity of the particle over time... I think it uses a property called 'Age' for that... So let say 5 seconds into the particle system playing I was to start giving a velocity that might adjust a partialce that Is going start up... to start going left... But not at the emitter... once the particle has left the emitter and is 5 sec into its life... or what ever the curve is keyed to. Anyways... Let me know if anybody can help with those outstanding issues I need to clear up before release the version 3.1 of the BabylonJS Toolkit
  4. Audio loop duplicating - Bug?

    Hi there, I've stumbled across some very weird audio behavior and can't seem to avoid it. I'm trying to loop a marker of my audio file, which works well on itself. Whenever pausing and resuming the audio loop at least once however, as soon as the next loop point is reached it will not stop the currently running audio and play from the marker but just add a new layer of audio that plays from the marker instead, while the old one just continues to play. And it keeps doing that for every loop. //Create { this.sfx_music = this.sound.add("key); this.sfx_music.allowMultiple = false; this.sfx_music.addMarker('turbo', 116.8696, 7.3846, 1, true); this.sfx_music.play('turbo'); } unpauseGame: function() { if(this.game.paused) { this.game.paused = false; this.sfx_music.resume(); } }, pauseGame: function() { this.sfx_music.pause(); this.game.paused = true; } Pausing the game without pausing the music doesn't cause this problem, but It's mandatory for me to pause the music when pausing the game.. Could this be a bug in sound.pause() or sound.resume()? I'm using Chrome but I have the same behavior in firefox as well. Please help! Best Zampano
  5. Game loop and Animation question

    Hey everyone, So Im new to game development, although Im a full stack JS dev for general sites and apps. I started getting into canvas animation and now Im here trying to learn some game animation stuff. My question is this: Do you generally do just about all animation in the game loop with requestAnimationFrame()? Or can you simply have renderer.render(stage) called in the game loop while outside of it you use GSAP or some other tweening mechanic to change the positioning props on objects/sprites? Iv tried it and it works, I just would like to know if its dumb or nonperformant. I also tried using my regular js tweening library to call `renderer.render(stage);` in its update callback and it looks the same (im just doing a simple animation generating snow-like particles that float down). I know that the supported game loop in PIXI has stuff for velocity and whatever but I really like my animation library's (http://animejs.com/) easing and elasticity options. Will calling renderer.render(stage) in the game loop while tweening outside the loop still be 60FPS? Or do I need to be updating in the game loop? If I have to do it in the game loop, does anyone have any tips/references for easing and all of that? Because I dont want to have to write my own easing functions to update in the game loop (and I suspect most people arent), and rather use an animation API for that. Im also brand new to PIXI and maybe it has its own easing and whatever that works inside the game loop. Cheers
  6. Spawning enemies at random period

    Third time from me today :D, So I want to spawn these customers at random millisecs every loop... The problem is that when the first number is generated it uses it(this specific number) for every loop after that? Any ideas? this is how I'm trying to do it, but I guess there is a better solution... I can't create a variable, since the same thing is going to happen: game.time.events.loop(Math.floor((Math.random() * 10)*1000), this.createCustomer, this);
  7. Greetings, Quick question: How do I dynamically update the arguments of this loop from the update function to reflect the actual coordinates of the pointer? (This loop is found in the create() function) Game.mouseTimer = game.time.events.loop( 100, Client.sendMousePos, Client.class, game.input.mousePointer.x, game.input.mousePointer.y ); I have already attempted several techniques, such as including this code snippet in the update function; However, it throws an Uncaught TypeError: Cannot set property '0' of undefined error. Game.mouseTimer.args[0] = game.input.mousePointer.x; Game.mouseTimer.args[1] = game.input.mousePointer.y; To go around the error, I tried to manually initialize the Game.mouseTimer.args array before the loop. This did indeed avoid the error; However, it only updated the arguments once. Thanks.
  8. Hello, I'm wondering if someone could help me solve this problem I have with 'Groups' in Phaser. So I have a group called 'enemy_wave' and it has 2 sprites attached to it: 'e_blue' and 'e_red'. Now, I want to 'kill' (sprite.kill();) 'e_blue' sprite and 'revive' (sprite.revive();) it later. Everytime I try to do that it also kills 'e_red', no matter how I put it. this.enemy_wave = game.add.group(); this.enemy_wave.enableBody = true; this.enemy_wave.physicsBodyType = Phaser.Physics.ARCADE; for (i = 0; i < system_var.length; i++) { for (j = 0; j < system_var[i].length; j++) { switch(system_var[i][j]){ case 'b': var e_blue = this.enemy_wave.create(40 + 40 * j, 40 + 40 * i, 'enemies'); this.enemy_wave.add(e_blue); break; case 'r': var e_red = this.enemy_wave.create(40 + 40 * j, 40 + 40 * i, 'enemies'); this.enemy_wave.add(e_red); break; } } } This is how I 'kill' sprites: this.enemy_wave.forEachAlive(function (e_blue) { e_blue.kill(); }, this); And this is how I 'revive' sprites: this.enemy_wave.forEachDead(function (e_blue) { e_blue.revive(); }, this); So yeah it doesn't matter if I kill 'e_blue' or 'e_red' because either way it 'kills'/'revives' all sprites attached to this group. How do I go about this? What seems wrong here? ~Thanks!
  9. Hey guys, I have a quick question about 'Groups' as I'm kinda new to this Phaser HTML5 game dev. So my plan is to create multiple groups and have control over each one of them. First thing that came into my mind is to create a 'for loop' and be done with! Problem is that I don't know how to assign different names for a variable (wave).Example: Instead of doing this: this.wave00 = game.add.group(); this.wave00.enableBody = true; this.wave00.physicsBodyType = Phaser.Physics.ARCADE; this.wave01 = game.add.group(); this.wave01.enableBody = true; this.wave01.physicsBodyType = Phaser.Physics.ARCADE; this.wave02 = game.add.group(); this.wave02.enableBody = true; this.wave02.physicsBodyType = Phaser.Physics.ARCADE; I am trying to do this: for(i=0; i<10; i++){ this.['wave'+i] = game.add.group(); this.['wave'+i].enableBody = true; this.['wave'+i].physicsBodyType = Phaser.Physics.ARCADE; } So I'm sure you got the idea but this (['wave'+i]) is the problem. Can someone help me with this? What is the correct way of writing it? I've been searching but maybe I'm not questioning this correctly. Thanks and sorry for the noob question!
  10. help with a loop

    Hi Im trying to make a level select buttons so a person can choose which level to play How can I make this.levelButton1,this.levelButton2 etc on the fly ? for (i = 1 ; i < 6; i ++){ this.levelButton = this.add.button(this.levelButtonWidth * (i * 1.8), 100, 'levelButton' + i); this.levelButton.inputEnabled = true; this.levelButton.events.onInputDown.add(function(){ console.log('You Pressed LevelButton' + i); // pass this value to GameState }, this); } I have tried this.levelButton = this.add.button(this.levelButtonWidth * (i * 1.8), 100, 'levelButton' + i); but I keep getting a null reference any help would be appreciated Eric
  11. Hi I have a script that I wish to implement so that if the player hits an enemy 3 times the game restarts, but it constally loops when touching, where am I going wrong ?? create function this.currentHits = 3; this.collisionHasOccurred = false; update function : this.game.physics.arcade.overlap(this.player, this.enemies, this.youLose, null, this); youlose function : youLose : function(player, enemies){ if (!this.collisionHasOccurred) { this.currentHits --; this.collisionHasOccurred = true; } else { this.collisionHasOccurred = false; } console.log(this.currentHits); console.log(this.collisionHasOccurred); if (this.currentHits === 0) { //this.game.state.start('Game'); console.log('GAME OVER'); } }, thanks in advance eric
  12. Hey, I was wondering if anyone knows how to play a MovieClip only once? For a code example, my code is pretty similar to the example below: http://pixijs.github.io/examples/index.html?s=basics&f=spritesheet.js&title=SpriteSheet Animation Thanks!
  13. Hi everyone. I have the looped timer : timer = this.game.time.create(false); timer.loop(Phaser.Timer.SECOND * 3, this.endTimer, this); timer.start(); Everything works good, but i want to play sound every ticked second, how to implement this?
  14. Hi, friends I'm a game music composer who has been composing music and sfx for game projects for several year. If you need cool music and sfx for your game, take a visit at my collection here http://bit.ly/JKMusicSFX All of My Music and SFX is Royalty Free. You need to buy them at first and then you can use them in all of your commercial projects without any additional fee. If you're interested in hiring me, please check this link http://bit.ly/CustomMusicProject Best, JAK
  15. Does Phaser have any loop size limits?

    Hi Sorry if this is in the docs somewhere, but I couldn't find it. Could someone please tell me if Phaser (or possibly Brackets) is deliberately limiting the size of my loops, as I can't seem to get them to work over about 32000 iterations. I did notice that JSbin has something called "loop protection" but offers a code to turn it off. Is there a way to do this in Phaser?
  16. EDIT: It seems to happen only in version 2.4.8. In 2.4.7 works perfectly. I will submit an issue to github. Hi, guys. I'm having a trouble with a background music that plays on my game playState. It works well if the player dies before the audio loops (the audio duration is 21 seconds), but if the player survives more than 21 seconds and the audio loops, I can't stop the music. Instead, when the create function of my playState comes on, it creates another audio and plays simultaneously. I have read many post related to audio here, but can't solve the problem. This is how I do it: Audio preload in load.js: game.load.audio('music', 'assets/background_music.mp3'); And in play.js in the create function: game.music = this.add.audio('music', 0.2, true); game.music.play(); And finally, in the gameOver function: game.music.destroy(); game.state.start('gameOver'); I had tried many approaches described here in the forum, as: Change the this.music variable to game.music, check if the game.music.isPlaying before create, stop it before call destroy, restart, but nothing helps. Thanks for your attention Phaser version 2.4.8
  17. 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!
  18. Hello everyone, in my application, I normally only need to render the 3D view after the user has changed some settings of the confugration or the view is being used (with either the mouse , finger or keyboard) the rest of the time no rendering is needed. But how can I know if Babylon is doing something that needs? For example: Can I look somewhere if the camera has stopped moving? (Especially when it's deaccelerating) Or an animation is running? Thanks for your answer! Kevin
  19. Problem with loops

    Hi everybody! I have a problem with a loop in my game. The problem is this: I have a loop that after certain seconds it executes and generates some sprites in the game (it takes it from a group), it works fine the first time. But after the specified seconds pass and the loop executes again it throws me this error: "Uncaught TypeError: Cannot read property 'apply' of undefined" Here's the Code (there are 3 loops in total, but for the example i just focused in the first). /Creation of the fire traps this.fireballs = game.add.group(); this.fireballs.createMultiple(100, 'fireball'); this.fireballs.callAll('animations.add', 'animations', 'shoot', [0,1,2,3], 16, true); game.physics.arcade.enable(this.fireballs); this.fireballs.enableBody = true; //Multiple Fire traps this.loop1 = game.time.events.loop(2000, this.activateMultipleFireTraps('1'), this); //this.loop2 = game.time.events.loop(4000, this.activateMultipleFireTraps(2), this); //this.loop3 = game.time.events.loop(6000, this.activateMultipleFireTraps(3), this); activateMultipleFireTraps: function(position){ if(position == '1'){ var firePositions = [[528, 7488], [528, 7360], [528, 7232], [528, 7088]]; var index = 0; for(index = 0; index < firePositions.length; index++){ var fire = this.fireballs.getFirstDead(); fire.anchor.setTo(0.5); fire.scale.setTo(0.5); fire.scale.x = -1; fire.reset(firePositions[index][0], firePositions[index][1]); fire.body.velocity.x = -150; fire.animations.play('shoot'); } } else if(position == 2){ var firePositions = [[0, 7552], [0, 7424], [0, 7296], [0, 7168]]; var index = 0; for(index = 0; index < firePositions.length; index++){ var fire = this.fireballs.getFirstDead(); fire.anchor.setTo(0.5); fire.scale.setTo(0.5); fire.scale.x = 1; fire.reset(firePositions[index][0], firePositions[index][1]); fire.body.velocity.x = 150; fire.animations.play('shoot'); } } else{ var firePositions = [[112, 7040], [256, 7040], [400, 7040]]; var index = 0; for(index = 0; index < firePositions.length; index++){ var fire = this.fireballs.getFirstDead(); fire.anchor.setTo(0.5); fire.scale.setTo(0.5); fire.scale.y = -1; fire.reset(firePositions[index][0], firePositions[index][1]); fire.body.velocity.y = 150; fire.animations.play('shoot'); } } }, I dont know why it doesnt work. Thanks!
  20. 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 !
  21. Seamless Audio Loops in Phaser

    I'm working on a game with seamless background music and figured I'd share my findings to help others. I'm just using Phaser's standard sound.play('', 0, 1, true) code to play loops. (Have since discovered I can also use sound.loopFull()). I didn't want to mess with outside solutions like seamlessLoop.js, which I'm not sure would work across all browsers anyway. Here's the run down on the file formats: OGG - Good for seamless loops in Firefox and Chrome. M4A - Good for seamless loops in iOS. When I first posted this I thought that I was stuck using the Apple Lossless codec (lossless = huge file sizes) because when I used any other M4A generating codec the resulting audio had blank space added at both ends. I wound up using the fre:ac open source audio converter which adds information for gapless playback according to its developer, who was extremely responsive and helpful (Thanks Robert!). Sure enough, the audio played seamlessly on my iPad with much smaller files. MP3 - Not good for seamless loops, but needed for IE. Even if your MP3 has no silence on either end, when the sound is done playing there will be a small audio gap before it loops. There are some techniques like the ones here that seem promising, so if I can overcome this issue I will post the code. Good for all other use cases because all browsers support it and it has the smallest file size of the three formats when exported with reasonable quality settings. So here's what I'm using to load my seamless loop audio. M4A is in a separate conditional because when I put it as the first option Firefox would load it instead of falling back to OGG and not play the sound. I'm loading all my other sounds as MP3s (in a different code block - not shown) to keep my total file size as low as possible. // load seamless intro audio loadLoop('musicIntro', 'intro_music_loop'); function loadLoop(key, file) { if (game.device.iOS || game.device.macOS) { game.load.audio(key, ['sounds/' + file + '.m4a']); } else { // Firefox and Chrome will use OGG // IE11 will fall back to MP3, which will have a small gap at the end before replaying game.load.audio(key, ['sounds/' + file + '.ogg', 'sounds/' + file + '.mp3']); } } Hope someone finds this helpful
  22. Read Json data with for loop

    Hello everyone, I have a texture atlas which is created by TextuePacker and there are different sizes images in it. Also i exported it with json hash file from it and load my phaser project as game.load.atlas(.., .., ...); The question is, how can i read all frame names and its properties from json file in a for loop? I've tried this, var frameData = game.cache.getFrameData('texture');for (var i = 0; i < frameData.total; i++) { var name = frameData.getFrameByName(i).name; //or// var name = frameData.getFrame(i).name; // or many things console.log(name); }but nothing. Thank you all.
  23. Seamless loop?

    I'm totally new at this forum, so this might an old topic. If so, I'm sorry. Anyway, I'm working with a html & javascript game in which i want a 20 second .mp3 to start and then loop. I'm fine with the user interaction to play, and I also got it to loop. But is there a way to make the loop as seamless as possible? As it is now, there's a notable pause between the end and the start of the mp3. Thanks in advance!
  24. no audio sprite

    Hi all, Do you think there is a way to do the same thing like here but with many audio files (no audio sprite) ? : http://phaser.io/examples/v2/audio/audio-sprite I tried to do it by myself but no succeed... Thank for any help !