Javascript move target around screen?

تعرفه تبلیغات در سایت
عنوان عکس عنوان عکس عنوان عکس عنوان عکس
عنوان عکس عنوان عکس عنوان عکس عنوان عکس
عنوان عکس عنوان عکس عنوان عکس عنوان عکس
عنوان عکس عنوان عکس عنوان عکس عنوان عکس
عنوان عکس عنوان عکس عنوان عکس عنوان عکس

آرشیو مطالب

جستجوگر

یافته ها در جستجو

    امکانات وب

    برچسب ها

    Vote count: 0

    So I'm working on a basic shooter, part of which involves moving a target around the screen. I'm using babylon.js as the engine and my goal is to have the target appear for 0.75 seconds on the screen, then disappear for 0.5 seconds, then reappear at a different random location. The current code I have for that is this:

    function moveTarget(canvas, scene){
      setTimeout( function (){
        scene.meshes[10].visibility = 0; //how I access the target object
        randX = genRandNum(minX, maxX); //This is a separate function that works
        randY = genRandNum(minY, maxY);
        scene.meshes[10].position = new BABYLON.Vector3(randX, randY, 
                     scene.meshes[10].position.z);
        scene.meshes[10].visibility = 1;
        x ++;
        if (x < amount){
          moveTarget(canvas, scene);
        }
      }, tarDuration * 1000)
    
      }
    

    which succeeds in everything except the 0.5 second delay between appearances of the target, ie currently it flashes from location to location with no space in between. I'm thinking that I need a second setTimeout but I'm not entirely sure how to include that or where it would go. Any pushes in the right direction would be much appreciated.

    asked 29 secs ago

  • مطالب مرتبط
  • loop through two arrays javascript to search an object by value
  • extract and remove element with two conditions in javascript array
  • how to make avoid user entering numbers for first two chars(but rest all chars must be numbers only) using javascript
  • Angular one: javascript timeout function
  • How are generated the big chunks of javascript code in big websites?
  • How can i add 1 second delay for JavaScript loop?
  • نویسنده : استخدام کار بازدید : 53 تاريخ : پنجشنبه 28 ارديبهشت 1396 ساعت: 9:08
    برچسب‌ها :