Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17082

Constrain Bullet to Player Code

$
0
0

@luke2125 wrote:

Hi,

Please look at the below code:

BulletRight:function(){
var bulletright = cc.instantiate(this.footballbulletright);
footballbulletright.setPositionX(this.posx);
footballbulletright.setPositionY(this.posy);
this.node.addChild(bulletright);
}

PlayerPositionXY:function(){
var posx = this.node.getPositionX();
var posy = this.node.getPositionY();
cc.log(posx,posy);
}

Now, what I'm trying to accomplish is that the bullet be constrain to the player, when I press spacebar to shoot bullet, I would like it to appear on the player or at least x+50 pixels to the right of the player and be constrain to the player, wherever that player moves around the screen, the bullet will spawn close to the player......Would appreciate any feedback........Thanks and God Bless....

Sincerely,

Sunday

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 17082

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>