title: Moving player using keyboard listeners
body: <p>I've got a player class, having <code>MoveUp</code>, <code>MoveLeft</code> and <code>MoveRight</code> functions.<br>
  At <code>MainScene.cpp</code> (my only scene so far), I've got a listener</p>
  
  <pre><code>auto keyboardListener = EventListenerKeyboard::create();
  keyboardListener-&gt;onKeyPressed = CC_CALLBACK_2(MainScene::keyPressed, this);
  keyboardListener-&gt;onKeyReleased = CC_CALLBACK_2(MainScene::keyReleased, this);
  
  Director::getInstance()-&gt;getEventDispatcher()-&gt;addEventListenerWithSceneGraphPriority(keyboardListener, this);
  </code></pre>
  
  <p>Also, I've got a pointer <code>player</code>, defined by</p>
  
  <pre><code>this-&gt;player = rootNode-&gt;getChildByName&lt;Player*&gt;("Player1");
  </code></pre>
  
  <p>Also, I've got a function <code>keyPressed</code> and <code>keyReleased</code> in <code>MainScene</code>.<br>
  In <code>keyPressed</code> function, I was scheduling functions with if's:</p>
  
  <pre><code>if (keyCode == cocos2d::EventKeyboard::KeyCode::KEY_D) { schedule(schedule_selector(MainScene::MoveRight)); }
  </code></pre>
  
  <p>But there was a problem, when I tried to do the same thing with objects instead of sprites and with functions located in separated class, not within the same file.<br>
  If I try to run code like this in <code>MainScene::keyPressed</code>:</p>
  
  <pre><code>if (keyCode == cocos2d::EventKeyboard::KeyCode::KEY_W) { this-&gt;player-&gt;MoveLeft(5); }
  </code></pre>
  
  <p>, <code>player</code> moves only once per key press (I want it to move till I release that key), and if I try to schedule it or do something like this, it doesn't work or there are errors.   </p>
  
  <p>I tried to make something with <code>CallFunc</code> and <code>CCCallFunc</code>, but nothing seems to work.<br>
  Could you please help me? :)</p>