Touch Question / Dilemma?

Hi,

I’m trying to implement the best method regarding Touch, using below:

http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/

for my game, but I have a question regarding it’s use…My game consists of below:

  1. Player - Will use Touch to move around the screen while dragging the finger
  2. Power Bullet Button ( HUD ) - Will press the Button to fire Bullets
  3. Player - Will press the actual player ( node ) to fire bullets…

So I have 3 objects that I need Touches on, what is the best way to implement this, right now I have:

  1. Power Bullet Button ( HUD )
    this.theubutton.on(cc.Node.EventType.TOUCH_START, function (event) {

  2. Player - Shoot Bullets
    this.node.on(cc.Node.EventType.TOUCH_START, function (event) {

  3. Player - Move Around
    this.node.on(cc.Node.EventType.TOUCH_START, function (touch,event) {

So as you can see I have 3 Touches…? Should I add the player as a child to the ground node, and transfer the Touch Method of the Player - Move around to the ground node and have the player move around as per Touch on ground node? Would really appreciate help regarding this question…Thanks and God Bless…

Sincerely,

Sunday

I think it’s pretty much your own choice.

Personally, I think use ground node to do player moving is a good idea, because it can be stopped by touch on Player. I would use TOUCH_END for HUD button, use TOUCH_START for shooting, a personal habit.

Detecting moving on Player is a bit difficult because it’s very easy to move your finger out of Player and you will no longer have the moving callback.

Hi @pandamicro,

Yes, that’s what I’m going to do, I’ve already set the ground floor as a Node, placed it on my player node via properties, and have applied the Touch, that way it won’t interfere with the Player Touch Fire Bullets and other Button Bullets… Thanks for the clarification…God Bless…

Sincerely,

Sunday