title: Game Bugg background slipping
body: <p>i'm working on this game, it has the background moving , so i created 2 backgrounds to keep it looping.
  now i wanted to add a slow motion feature, when i click the button the background slows down perfectly but later i can see white space between the 2 backgrounds.
  if i start the game and i don't click on the slow motion button, the backgrounds keep on looping perfectly.
  here is my code:</p>
  <pre><code> @Override
      protected void onDraw(Canvas canvas) {
          super.onDraw(canvas);
          getHandler().postDelayed(runnable,10);
  
          // draw Background
          background1.setX(background1.getX() - speed);
          background2.setX(background2.getX() - speed);
          canvas.drawBitmap(background1.getBitmap(), background1.getX() ,background1.getY(),null);
          canvas.drawBitmap(background2.getBitmap(), background2.getX(),background2.getY(),null);
  
          if (background1.getX() + background1.getBitmap().getWidth() &lt;= 0) {
              background1.setX(Constants.screenWidth );
          }
          if (background2.getX() + background1.getBitmap().getWidth() &lt;= 0) {
              background2.setX(Constants.screenWidth );
          }
   }
  
      private final Runnable decreaseSpeedRunnable = new Runnable() {
          @Override
          public void run() {
              speed --;
              if (speed &lt;= 1) {
                  speed = 1;
              } else {
                  getHandler().postDelayed(this,50);
              }
          }
      };
  
  @Override
      public boolean onTouchEvent(MotionEvent event) {
  
          //slowmotion button
          if (event.getAction() == MotionEvent.ACTION_DOWN) {
              if (event.getX() &gt; slowmoButton.getX() &amp;&amp; event.getX() &lt; slowmoButton.getX() + slowmoButton.getBitmap().getWidth() &amp;&amp; event.getY() &gt; slowmoButton.getY() &amp;&amp; event.getY() &lt; slowmoButton.getY() + slowmoButton.getBitmap().getWidth()) {
                  startSlowMotion();
              }
          }
          if (event.getAction() == MotionEvent.ACTION_UP){
              speed = (int)(10 * Constants.screenWidthRatio);
              stopSlowMotion();
          }
  
          if(event.getAction() == MotionEvent.ACTION_MOVE) {
              if (!(event.getX() &gt; slowmoButton.getX() &amp;&amp; event.getX() &lt; slowmoButton.getX() + slowmoButton.getBitmap().getWidth() &amp;&amp; event.getY() &gt; slowmoButton.getY() &amp;&amp; event.getY() &lt; slowmoButton.getY() + slowmoButton.getBitmap().getWidth())) {
                  speed = (int)(10 * Constants.screenWidthRatio);
                  stopSlowMotion();
  
              }
          }
  
          //
          return true;
      }
  
      private void startSlowMotion() {
          getHandler().postDelayed(decreaseSpeedRunnable,50);
      }
      private void stopSlowMotion() {
          getHandler().removeCallbacks(decreaseSpeedRunnable);
      }
  </code></pre>
  <p>here is a picture of the bug :
  <a href="https://i.stack.imgur.com/Gpijh.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gpijh.jpg" alt="Bug" /></a></p>
  <p>thank you in advance.</p>