Skip to content

Commit 094541d

Browse files
committed
Removed dirty and just properties as no longer required, also removed reset method
1 parent 4ab7fe1 commit 094541d

1 file changed

Lines changed: 12 additions & 139 deletions

File tree

src/input/Pointer.js

Lines changed: 12 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ var Pointer = new Class({
7070

7171
/**
7272
* The DOM element the Pointer was pressed down on, taken from the DOM event.
73+
* In a default set-up this will be the Canvas that Phaser is rendering to, or the Window element.
7374
*
7475
* @name Phaser.Input.Pointer#downElement
7576
* @type {any}
@@ -80,6 +81,7 @@ var Pointer = new Class({
8081

8182
/**
8283
* The DOM element the Pointer was released on, taken from the DOM event.
84+
* In a default set-up this will be the Canvas that Phaser is rendering to, or the Window element.
8385
*
8486
* @name Phaser.Input.Pointer#upElement
8587
* @type {any}
@@ -347,46 +349,6 @@ var Pointer = new Class({
347349
*/
348350
this.isDown = false;
349351

350-
/**
351-
* A dirty flag for this Pointer, used internally by the Input Plugin.
352-
*
353-
* @name Phaser.Input.Pointer#dirty
354-
* @type {boolean}
355-
* @default false
356-
* @since 3.0.0
357-
*/
358-
this.dirty = false;
359-
360-
/**
361-
* Is this Pointer considered as being "just down" or not?
362-
*
363-
* @name Phaser.Input.Pointer#justDown
364-
* @type {boolean}
365-
* @default false
366-
* @since 3.0.0
367-
*/
368-
this.justDown = false;
369-
370-
/**
371-
* Is this Pointer considered as being "just up" or not?
372-
*
373-
* @name Phaser.Input.Pointer#justUp
374-
* @type {boolean}
375-
* @default false
376-
* @since 3.0.0
377-
*/
378-
this.justUp = false;
379-
380-
/**
381-
* Is this Pointer considered as being "just moved" or not?
382-
*
383-
* @name Phaser.Input.Pointer#justMoved
384-
* @type {boolean}
385-
* @default false
386-
* @since 3.0.0
387-
*/
388-
this.justMoved = false;
389-
390352
/**
391353
* Did the previous input event come from a Touch input (true) or Mouse? (false)
392354
*
@@ -466,15 +428,6 @@ var Pointer = new Class({
466428
* @since 3.16.0
467429
*/
468430
this.time = 0;
469-
470-
/**
471-
* The game frame when this Pointer was most recently updated by a DOM Event.
472-
*
473-
* @name Phaser.Input.Pointer#lastAction
474-
* @type {integer}
475-
* @since 3.18.0
476-
*/
477-
this.lastAction = -1;
478431
},
479432

480433
/**
@@ -494,36 +447,6 @@ var Pointer = new Class({
494447
return camera.getWorldPoint(this.x, this.y, output);
495448
},
496449

497-
/**
498-
* Resets the temporal properties of this Pointer.
499-
* This method is called automatically each frame by the Input Manager.
500-
*
501-
* @method Phaser.Input.Pointer#reset
502-
* @private
503-
* @since 3.0.0
504-
*/
505-
reset: function (time)
506-
{
507-
var currentFrame = this.manager.game.getFrame();
508-
509-
if (this.lastAction < currentFrame)
510-
{
511-
// There was a DOM Event just prior to the game step
512-
this.dirty = false;
513-
514-
this.justDown = false;
515-
this.justUp = false;
516-
this.justMoved = false;
517-
518-
this.time = time;
519-
520-
this.movementX = 0;
521-
this.movementY = 0;
522-
523-
this.lastAction = currentFrame;
524-
}
525-
},
526-
527450
/**
528451
* Calculates the motion of this Pointer, including its velocity and angle of movement.
529452
* This method is called automatically each frame by the Input Manager.
@@ -583,14 +506,6 @@ var Pointer = new Class({
583506
*/
584507
up: function (event)
585508
{
586-
var time = event.timeStamp;
587-
var currentFrame = this.manager.game.getFrame();
588-
589-
if (currentFrame > this.lastAction)
590-
{
591-
this.reset(time);
592-
}
593-
594509
if ('buttons' in event)
595510
{
596511
this.buttons = event.buttons;
@@ -609,14 +524,11 @@ var Pointer = new Class({
609524
this.primaryDown = false;
610525
this.upX = this.x;
611526
this.upY = this.y;
612-
this.upTime = time;
527+
this.upTime = event.timeStamp;
613528
}
614529

615-
this.justUp = true;
616530
this.isDown = false;
617531

618-
this.dirty = true;
619-
620532
this.wasTouch = false;
621533
},
622534

@@ -631,14 +543,6 @@ var Pointer = new Class({
631543
*/
632544
down: function (event)
633545
{
634-
var time = event.timeStamp;
635-
var currentFrame = this.manager.game.getFrame();
636-
637-
if (currentFrame > this.lastAction)
638-
{
639-
this.reset(time);
640-
}
641-
642546
if ('buttons' in event)
643547
{
644548
this.buttons = event.buttons;
@@ -657,14 +561,11 @@ var Pointer = new Class({
657561
this.primaryDown = true;
658562
this.downX = this.x;
659563
this.downY = this.y;
660-
this.downTime = time;
564+
this.downTime = event.timeStamp;
661565
}
662566

663-
this.justDown = true;
664567
this.isDown = true;
665568

666-
this.dirty = true;
667-
668569
this.wasTouch = false;
669570
},
670571

@@ -679,14 +580,6 @@ var Pointer = new Class({
679580
*/
680581
move: function (event)
681582
{
682-
var time = event.timeStamp;
683-
var currentFrame = this.manager.game.getFrame();
684-
685-
if (currentFrame > this.lastAction)
686-
{
687-
this.reset(time);
688-
}
689-
690583
if ('buttons' in event)
691584
{
692585
this.buttons = event.buttons;
@@ -699,16 +592,12 @@ var Pointer = new Class({
699592

700593
if (this.manager.mouse.locked)
701594
{
702-
// Multiple DOM events may occur within one frame, but only one Phaser event will fire
595+
// Multiple DOM events may occur within one frame, but only one Phaser event will fire
703596
this.movementX += event.movementX || event.mozMovementX || event.webkitMovementX || 0;
704597
this.movementY += event.movementY || event.mozMovementY || event.webkitMovementY || 0;
705598
}
706599

707-
this.justMoved = true;
708-
709-
this.moveTime = time;
710-
711-
this.dirty = true;
600+
this.moveTime = event.timeStamp;
712601

713602
this.wasTouch = false;
714603
},
@@ -721,9 +610,8 @@ var Pointer = new Class({
721610
* @since 3.0.0
722611
*
723612
* @param {TouchEvent} event - The Touch Event to process.
724-
* @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
725613
*/
726-
touchstart: function (event, time)
614+
touchstart: function (event)
727615
{
728616
if (event['pointerId'])
729617
{
@@ -746,13 +634,10 @@ var Pointer = new Class({
746634
this.primaryDown = true;
747635
this.downX = this.x;
748636
this.downY = this.y;
749-
this.downTime = time;
637+
this.downTime = event.timeStamp;
750638

751-
this.justDown = true;
752639
this.isDown = true;
753640

754-
this.dirty = true;
755-
756641
this.wasTouch = true;
757642
this.wasCanceled = false;
758643
},
@@ -765,20 +650,15 @@ var Pointer = new Class({
765650
* @since 3.0.0
766651
*
767652
* @param {TouchEvent} event - The Touch Event to process.
768-
* @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
769653
*/
770-
touchmove: function (event, time)
654+
touchmove: function (event)
771655
{
772656
this.event = event;
773657

774658
// Sets the local x/y properties
775659
this.manager.transformPointer(this, event.pageX, event.pageY, true);
776660

777-
this.justMoved = true;
778-
779-
this.moveTime = time;
780-
781-
this.dirty = true;
661+
this.moveTime = event.timeStamp;
782662

783663
this.wasTouch = true;
784664
},
@@ -791,9 +671,8 @@ var Pointer = new Class({
791671
* @since 3.0.0
792672
*
793673
* @param {TouchEvent} event - The Touch Event to process.
794-
* @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
795674
*/
796-
touchend: function (event, time)
675+
touchend: function (event)
797676
{
798677
this.buttons = 0;
799678

@@ -807,13 +686,10 @@ var Pointer = new Class({
807686
this.primaryDown = false;
808687
this.upX = this.x;
809688
this.upY = this.y;
810-
this.upTime = time;
689+
this.upTime = event.timeStamp;
811690

812-
this.justUp = true;
813691
this.isDown = false;
814692

815-
this.dirty = true;
816-
817693
this.wasTouch = true;
818694
this.wasCanceled = false;
819695

@@ -837,11 +713,8 @@ var Pointer = new Class({
837713

838714
this.primaryDown = false;
839715

840-
this.justUp = false;
841716
this.isDown = false;
842717

843-
this.dirty = true;
844-
845718
this.wasTouch = true;
846719
this.wasCanceled = true;
847720

0 commit comments

Comments
 (0)