Jump to content

drag the camera


4ucai
 Share

Recommended Posts

  • 5 months later...

This should be working, I cannot test it on touchable device now... later I will, now I am going to sleeep :P

http://jsfiddle.net/luckylooke/YHj24/7/

Ok, I have tested it and it doesnt work... I decided to bypass phaser as I am confused from documentation and make it pure javascript ;) If anybody can remade it in better phaserway I am looking forward to see it :P

 

Working pure javascript solution (tested):

http://jsfiddle.net/YHj24/8/

Link to comment
Share on other sites

Thx for your snippet, works well for me.

 

For your problem, is there anyway to pass a callbacks that will be fired when start/stop dragging an object ? (That way you could have a switch variable to enable camera dragging or not)

Link to comment
Share on other sites

Thx for your snippet, works well for me.

 

For your problem, is there anyway to pass a callbacks that will be fired when start/stop dragging an object ? (That way you could have a switch variable to enable camera dragging or not)

 

You give me idea, but it is very weird solution, because you need to setup every draggable entity in game :/

Here it is: http://jsfiddle.net/luckylooke/YHj24/12/

 

 

EDIT: Heureka

I have made new solution, working without need to disabling world drag in every touchable entity ;)

Little mix of pure js events and phaser event handlers:

http://jsfiddle.net/luckylooke/YHj24/15/

 

TESTED WITH MOUSE and TOUCHES  ;)

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

1. Only Phaser whithout hacks

http://jsfiddle.net/YHj24/21/

 

2. In typescript:
 

        move_camera_by_pointer(o_pointer : Phaser.Pointer) {            if (!o_pointer.timeDown) { return; }            if (o_pointer.isDown && !o_pointer.targetObject) {                if (this.o_mcamera) {                    this.game.camera.x += this.o_mcamera.x - o_pointer.position.x;                    this.game.camera.y += this.o_mcamera.y - o_pointer.position.y;                }                this.o_mcamera = o_pointer.position.clone();            }            if (o_pointer.isUp) { this.o_mcamera = null; }        }
Link to comment
Share on other sites

 

Hi,

1. Only Phaser whithout hacks

http://jsfiddle.net/YHj24/21/

 

2. In typescript:

 

        move_camera_by_pointer(o_pointer : Phaser.Pointer) {            if (!o_pointer.timeDown) { return; }            if (o_pointer.isDown && !o_pointer.targetObject) {                if (this.o_mcamera) {                    this.game.camera.x += this.o_mcamera.x - o_pointer.position.x;                    this.game.camera.y += this.o_mcamera.y - o_pointer.position.y;                }                this.o_mcamera = o_pointer.position.clone();            }            if (o_pointer.isUp) { this.o_mcamera = null; }        }

Beautiful, thanks ;)

Link to comment
Share on other sites

  • 6 months later...
  • 1 month later...
  • 1 year later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...