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...

I've added a modification to this as well. This is a spin off of lokmahkov.

 

I wanted to give the camera a bit of velocity so that you could drag and let it fly for a bit before it came to a rest, so you could 'flick' the camera.

 

You can play with the settings but here's the fiddle for it:  http://jsfiddle.net/3c4jc2b8/1/

Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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