Jump to content

create a pseudo editor inside Phaser


espace
 Share

Recommended Posts

hi and happy new year.

to design my interface i use this part of snippet. it's simple and when i want to catch the position of my "this" i see the ruler in chrome dev tools or in firefox dev tools.

 
I was wondering if it would not be possible to retrieve the coordinates of my object directly after I moved it.
For example with another button that activates a function...
The problem is that I do not see how to say this.x = this_x_after_drag and then keep this data so that when refreshing my page, the object is at the new coordinate.

Do you have a track?
class_name = function(game){
	Phaser.Sprite.call(this,game,0,0,'image')
	this.flag_drag=true

	this.flag_drag && this.allow_drag(this)
} 

class_name.prototype.allow_drag = function(obj) {
	obj.inputEnabled=true	
	obj.input.enableDrag(true)
}

 

 

 

Link to comment
Share on other sites

A drag is one down event, a lot of move events, then an up event (usually... screen/canvas edges can make this a little complicated). Why not store the position during the move events during a drag?

As far as persisting the data, it depends. Does your game have a server connected to a database? Is it okay if it's only stored in the user's browser (you can use localStorage)? Do you mind it getting stored in someone else's storage (use Firebase)?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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