2 Replies - 533 Views - Last Post: 06 August 2014 - 09:48 AM

#1 codePenguin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 06-August 14

Why declare key left and right false if it is moving left and right?

Posted 06 August 2014 - 09:40 AM

 var sprite =document.querySelector('.sprite'),
                      key ={left:false, right:false},
                      trans=0,
                      property=getTransformProperty(sprite);


Is This A Good Question/Topic? 0
  • +

Replies To: Why declare key left and right false if it is moving left and right?

#2 BetaWar  Icon User is online

  • #include "soul.h"
  • member icon

Reputation: 1199
  • View blog
  • Posts: 7,306
  • Joined: 07-September 06

Re: Why declare key left and right false if it is moving left and right?

Posted 06 August 2014 - 09:42 AM

Well, given that you aren't showing us how the code is actually used we can only guess. But I'd say they are probably declaring them both false because they need to know if the key is being held down, so if the value was anything other than false it would try to move the sprite to the left or right.
Was This Post Helpful? 1
  • +
  • -

#3 codePenguin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 06-August 14

Re: Why declare key left and right false if it is moving left and right?

Posted 06 August 2014 - 09:48 AM

Thank you thats all I needed to know :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1