@@ -337,17 +337,17 @@ cc.EGLView = cc.Class.extend(/** @lends cc.EGLView# */{
337
337
director . _winSizeInPoints = this . getDesignResolutionSize ( ) ;
338
338
339
339
if ( cc . renderContextType === cc . CANVAS ) {
340
- var locWidth = 0 , locHeight = 0 ;
341
340
if ( this . _resolutionPolicy === cc . RESOLUTION_POLICY . SHOW_ALL ) {
342
- locWidth = ( this . _screenSize . width - viewPortW ) / 2 ;
343
- locHeight = - ( this . _screenSize . height - viewPortH ) / 2 ;
344
- var context = cc . renderContext ;
345
- context . beginPath ( ) ;
346
- context . rect ( locWidth , - viewPortH + locHeight , viewPortW , viewPortH ) ;
347
- context . clip ( ) ;
348
- context . closePath ( ) ;
341
+ var locHeight = Math . abs ( this . _screenSize . height - viewPortH ) / 2 ;
342
+ cc . canvas . width = viewPortW ;
343
+ cc . canvas . height = viewPortH ;
344
+ cc . container . style . width = viewPortW + "px" ;
345
+ cc . container . style . height = viewPortH + "px" ;
346
+ cc . renderContext . translate ( 0 , viewPortH ) ;
347
+ this . _ele . style . paddingTop = locHeight + "px" ;
348
+ this . _ele . style . paddingBottom = locHeight + "px" ;
349
+ this . _viewPortRect = cc . rect ( 0 , 0 , viewPortW , viewPortH ) ;
349
350
}
350
- cc . renderContext . translate ( locWidth , locHeight ) ;
351
351
cc . renderContext . scale ( this . _scaleX , this . _scaleY ) ;
352
352
} else {
353
353
// reset director's member variables to fit visible rect
@@ -653,10 +653,12 @@ cc.EGLView = cc.Class.extend(/** @lends cc.EGLView# */{
653
653
var ys = [ ] ;
654
654
655
655
var i = 0 ;
656
+ var touch ;
656
657
for ( var j = 0 ; j < touches . length ; j ++ ) {
657
- ids [ i ] = j ;
658
- xs [ i ] = touches [ j ] . getLocation ( ) . x ;
659
- ys [ i ] = touches [ j ] . getLocation ( ) . y ;
658
+ touch = touches [ j ] ;
659
+ ids [ i ] = touch . getId ( ) || j ;
660
+ xs [ i ] = touch . getLocation ( ) . x ;
661
+ ys [ i ] = touch . getLocation ( ) . y ;
660
662
++ i ;
661
663
}
662
664
this . handleTouchesBegin ( i , ids , xs , ys ) ;
@@ -668,10 +670,12 @@ cc.EGLView = cc.Class.extend(/** @lends cc.EGLView# */{
668
670
var ys = [ ] ;
669
671
670
672
var i = 0 ;
673
+ var touch ;
671
674
for ( var j = 0 ; j < touches . length ; j ++ ) {
672
- ids [ i ] = j ;
673
- xs [ i ] = touches [ j ] . getLocation ( ) . x ;
674
- ys [ i ] = touches [ j ] . getLocation ( ) . y ;
675
+ touch = touches [ j ] ;
676
+ ids [ i ] = touch . getId ( ) || j ;
677
+ xs [ i ] = touch . getLocation ( ) . x ;
678
+ ys [ i ] = touch . getLocation ( ) . y ;
675
679
++ i ;
676
680
}
677
681
this . handleTouchesMove ( i , ids , xs , ys ) ;
@@ -683,10 +687,12 @@ cc.EGLView = cc.Class.extend(/** @lends cc.EGLView# */{
683
687
var ys = [ ] ;
684
688
685
689
var i = 0 ;
690
+ var touch ;
686
691
for ( var j = 0 ; j < touches . length ; j ++ ) {
687
- ids [ i ] = j ;
688
- xs [ i ] = touches [ j ] . getLocation ( ) . x ;
689
- ys [ i ] = touches [ j ] . getLocation ( ) . y ;
692
+ touch = touches [ j ] ;
693
+ ids [ i ] = touch . getId ( ) || j ;
694
+ xs [ i ] = touch . getLocation ( ) . x ;
695
+ ys [ i ] = touch . getLocation ( ) . y ;
690
696
++ i ;
691
697
}
692
698
this . handleTouchesEnd ( i , ids , xs , ys ) ;
@@ -698,10 +704,12 @@ cc.EGLView = cc.Class.extend(/** @lends cc.EGLView# */{
698
704
var ys = [ ] ;
699
705
700
706
var i = 0 ;
707
+ var touch ;
701
708
for ( var j = 0 ; j < touches . length ; j ++ ) {
702
- ids [ i ] = j ;
703
- xs [ i ] = touches [ j ] . getLocation ( ) . x ;
704
- ys [ i ] = touches [ j ] . getLocation ( ) . y ;
709
+ touch = touches [ j ] ;
710
+ ids [ i ] = touch . getId ( ) || j ;
711
+ xs [ i ] = touch . getLocation ( ) . x ;
712
+ ys [ i ] = touch . getLocation ( ) . y ;
705
713
++ i ;
706
714
}
707
715
this . handleTouchesCancel ( i , ids , xs , ys ) ;
0 commit comments