1 var SlopeBlockClass = function(ownerStage, args)
3 SlopeBlockClass.base.apply(this, arguments);
5 var colLH = args[1], colRH = args[2];
7 this.collisionLeftHeight = colLH; //
\8d¶
\8fã
\82©
\82ç
\95Ó
\82è
\94»
\92è
\97Ì
\88æ
\82Ü
\82Å
\82Ì
\8d\82\82³
8 this.collisionRightHeight = colRH; //
\89E
\8fã
\82©
\82ç
\95Ó
\82è
\94»
\92è
\97Ì
\88æ
\82Ü
\82Å
\82Ì
\8d\82\82³
10 //
\83f
\83o
\83b
\83O
\8fî
\95ñ
\82ð
\89æ
\96Ê
\82É
\95\
\8e¦
11 this.enableDebugMode = false;
13 //
\83f
\83o
\83b
\83O
\8fî
\95ñ
18 }.extend(BlockClass, {
19 isOverlappedWith: function(x1, y1, x2, y2){
24 //
\83I
\83u
\83W
\83F
\83N
\83g
\96{
\91Ì
\95\94\95ª
\82É
\8fd
\82È
\82é
\82©
\82Ç
\82¤
\82©
\82ð
\92²
\82×
\82é
25 //
\82±
\82Ì
\8aÖ
\90\94\82ªfalse
\82ð
\95Ô
\82µ
\82½
\8e\9e\82Ì
\88ø
\90\94\82Ì
\94Í
\88Í
\82Ö
\82Í
\83I
\83u
\83W
\83F
\83N
\83g
\82ª
\88Ú
\93®
\82Å
\82«
\82é
\81B
26 //true
\82©
\82ÂisPhantom==false
\82Ì
\8e\9e\82Í
\8fÕ
\93Ë
\82·
\82é
\81B
28 //
\83f
\83o
\83b
\83O
\8fî
\95ñ
33 if(this.collisionLeftHeight != this.collisionRightHeight){
34 return this.crossLineJudge(x1, y2 - 1, x2, y2 - 1,
35 this.origin.x, this.origin.y + this.collisionLeftHeight,
36 this.origin.x + this.size.x - 1, this.origin.y + this.collisionRightHeight);
38 //
\83`
\83F
\83b
\83N
\82·
\82é
\93ñ
\82Â
\82Ì
\90ü
\95ª
\82ª
\95½
\8ds
\82¾
\82Æ
\93\96\82½
\82è
\94»
\92è
\82É
\98R
\82ê
\82é
\82Ì
\82Å
\81A
\93\96\82½
\82è
\94»
\92è
\82ª
\90\85\95½
\82È
\8fê
\8d\87\82Í
\91¼
\82Ì
\8e®
\82ð
\97\98\97p
\82·
\82é
\81B
39 if(this.collisionLeftHeight >= this.size.y){
42 return (x2 > (this.origin.x + this.collisionMargin.left)) &&
43 (x1 <= (this.origin.x + this.size.x - this.collisionMargin.right)) &&
44 (y2 > (this.origin.y + this.collisionMargin.top + this.collisionLeftHeight)) &&
45 (y1 <= (this.origin.y + this.size.y - this.collisionMargin.bottom));
47 //
\8dÀ
\95W p1,p2
\82ð
\8c\8b\82Ô
\90ü
\95ª
\82Æ
\8dÀ
\95W q1,q2
\82ð
\8c\8b\82Ô
\90ü
\95ª
\82ª
\8cð
\8d·
\82µ
\82Ä
\82¢
\82é
\82©
\82ð
\92²
\82×
\82é
48 //
\82½
\82¾
\82µ
\81A
\90ü
\95ª
\82ª
\8fd
\82È
\82Á
\82Ä
\82¢
\82é
\8fê
\8d\87(3
\93_,4
\93_
\82ª
\88ê
\92¼
\90ü
\8fã
\82É
\82 \82é)
\81A
\81u
\8cð
\8d·
\82µ
\82Ä
\82¢
\82é
\81v
\81A
\82Æ
\94»
\92è
\82µ
\82Ü
\82·
\81B
49 crossLineJudge: function(p1x, p1y, p2x, p2y, q1x, q1y, q2x, q2y){
51 if((p1x < q1x && p1x < q2x) || (p2x > q1x && p2x > q2x)){
55 if((p2x < q1x && p2x < q2x) || (p1x > q1x && p1x > q2x)){
60 if((p1y < q1y && p1y < q2y) || (p2y > q1y && p2y > q2y)){
64 if((p2y < q1y && p2y < q2y) || (p1y > q1y && p1y > q2y)){
68 return !((((p1x - p2x)*(q1y-p1y)+(p1y-p2y)*(p1x-q1x))*((p1x-p2x)*(q2y-p1y)+(p1y-p2y)*(p1x-q2x))>0) ||
69 (((q1x - q2x)*(p1y-q1y)+(q1y-q2y)*(q1x-p1x))*((q1x-q2x)*(p2y-q1y)+(q1y-q2y)*(q1x-p2x))>0));
70 //
\8eQ
\8dl http://www5d.biglobe.ne.jp/~tomoya03/shtml/algorithm/IntersectionEX.htm
72 draw : function(x, y){
73 SlopeBlockClass.base.prototype.draw.apply(this, arguments);
75 if(this.enableDebugMode)
77 var xz = this.origin.x - x;
78 this.ownerStage.mainContext.save();
79 this.ownerStage.mainContext.beginPath();
80 this.ownerStage.mainContext.strokeStyle='#0000ff';
81 this.ownerStage.mainContext.moveTo(x,y + this.collisionLeftHeight);
82 this.ownerStage.mainContext.lineTo(x + this.size.x + 1,y + this.collisionRightHeight);
83 this.ownerStage.mainContext.stroke();
84 this.ownerStage.mainContext.beginPath();
85 this.ownerStage.mainContext.strokeStyle='#ff0000';
86 this.ownerStage.mainContext.moveTo(this.x1 - xz,this.y2);
87 this.ownerStage.mainContext.lineTo(this.x2 - xz,this.y2);
88 this.ownerStage.mainContext.stroke();
89 this.ownerStage.mainContext.restore();
92 debugDraw: function(x, y){
93 var xz = this.origin.x - x;
95 if(this.collisionLeftHeight < this.size.y && this.collisionRightHeight < this.size.y){
96 this.ownerStage.collisionMapContext.beginPath();
97 this.ownerStage.collisionMapContext.moveTo(x, y + this.collisionLeftHeight);
98 this.ownerStage.collisionMapContext.lineTo(x + this.size.x, y + this.collisionRightHeight);
99 this.ownerStage.collisionMapContext.lineTo(x + this.size.x, y + this.size.y);
100 this.ownerStage.collisionMapContext.lineTo(x, y + this.size.y);
101 this.ownerStage.collisionMapContext.closePath();
102 this.ownerStage.collisionMapContext.stroke();
104 this.ownerStage.collisionMapContext.beginPath();
105 this.ownerStage.collisionMapContext.moveTo(x, y + this.collisionLeftHeight);
106 this.ownerStage.collisionMapContext.lineTo(x + this.size.x, y + this.collisionRightHeight);
107 this.ownerStage.collisionMapContext.stroke();
111 //
\82±
\82Ì
\83N
\83\89\83X
\82Ì
\83C
\83\93\83X
\83^
\83\93\83X
\82Ìtick
\82ð
\8cÄ
\82Ñ
\8fo
\82³
\82È
\82¢
\82æ
\82¤
\82É
\90Ý
\92è
\81i
\8d\82\91¬
\89»
\81j
112 SlopeBlockClass.tick = function(){return false;};