Hi everybody, I am new to game programming and I have a question about my game logic.
In my game there is a balloon that is supposed to collect some stars. the balloon moves with the keyboard. When the balloon hovers over a star, the star will go in to the balloon. In order to do that I created a script for my balloon and added a
cc.eventManager.addListener to it and in
update: function (dt) I managed to move the balloon when the keyboard keys are pressed. Now my balloon works fine. Then I added some stars to my
mainGame.js script, and there in
update: function (dt) for the mainGame, I calculated the distance between the star and balloon, if they are close enough, the star will go into the balloon.
Now I want to do something else. In my game there is an evil force that tries to eat the balloon, When the key is not pressed (the balloon is not moving) this evil force(at the top corner of the screen) will pull the balloon to itself (when there is at least one star in it). This means i should implement something like this:
var jumpUp = cc.moveTo(this.jumpDuration, evilForcePosition).easing(cc.easeCubicActionOut()) this.ballon.runAction(jumpUp);
but I don’t know where and how to do so. I tried to put this action in
update: function (dt) of
mainGame.js but I got weird outcome.
My question is this: How can I force the balloon to go somewhere when the input keys are not pressed?