ผลต่างระหว่างรุ่นของ "01219245/cocos2d/Platform1"

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
 
(ไม่แสดง 5 รุ่นระหว่างกลางโดยผู้ใช้คนเดียวกัน)
แถว 10: แถว 10:
 
== Collision detection: cc.Rect ==
 
== Collision detection: cc.Rect ==
  
Previously, we have implemented our own collision detection routine.  However, Cocos2d-html5 has provided us with a few nice collision detection tools.
+
Previously, we have implemented our own collision detection routine.  However, Cocos2d-html5 has provided us with a few nice collision detection tools. See [http://www.cocos2d-x.org/reference/html5-js/V2.2.2/symbols/src/E__Projects_cocos2d-html5_cocos2d_core_cocoa_CCGeometry.js.html code here.]
 +
 
 +
Related functions are:
 +
 
 +
* Creation: <tt>cc.rect</tt>
 +
* Accessing functions: <tt>cc.rectGetMaxX</tt>, <tt>cc.rectGetMidX</tt>, <tt>cc.rectGetMinX</tt>, <tt>cc.rectGetMaxY</tt>, <tt>cc.rectGetMidY</tt>, <tt>cc.rectGetMinY</tt>
 +
* Testing:
 +
** <tt>cc.rectEqualToRect</tt>
 +
** <tt>cc.rectContainsRect</tt>
 +
** <tt>cc.rectContainsPoint</tt>
 +
** <tt>cc.rectIntersectsRect</tt>
 +
** <tt>cc.rectOverlapsRect</tt>
 +
* Manipulation:
 +
** <tt>cc.rectUnion</tt>
 +
** <tt>cc.rectIntersection</tt>
  
 
=== Bounding boxes and world co-ordinates ===
 
=== Bounding boxes and world co-ordinates ===
แถว 17: แถว 31:
  
 
=== Falling on top ===
 
=== Falling on top ===
 +
[[Image:Cocos-platform-fall-through.png]]
  
 
== Example code ==
 
== Example code ==
แถว 22: แถว 37:
 
[[Image:Cocos-jumper-platform.png]]
 
[[Image:Cocos-jumper-platform.png]]
  
View its [https://bitbucket.org/jittat/cocos2d-html5-jump git repo at Bitbucket].
+
This is a sample Cocos2d-html5 project that has a jumper over a set of blocks.  It implements simple physical movement and rectangular collision detection.  View its [https://bitbucket.org/jittat/cocos2d-html5-jump source code at Bitbucket].

รุ่นแก้ไขปัจจุบันเมื่อ 05:39, 26 กุมภาพันธ์ 2557

This is part of 01219245.

This guide is very short. It only discuss various techniques in implementing platform games.

Here are a few useful links:

Collision detection: cc.Rect

Previously, we have implemented our own collision detection routine. However, Cocos2d-html5 has provided us with a few nice collision detection tools. See code here.

Related functions are:

  • Creation: cc.rect
  • Accessing functions: cc.rectGetMaxX, cc.rectGetMidX, cc.rectGetMinX, cc.rectGetMaxY, cc.rectGetMidY, cc.rectGetMinY
  • Testing:
    • cc.rectEqualToRect
    • cc.rectContainsRect
    • cc.rectContainsPoint
    • cc.rectIntersectsRect
    • cc.rectOverlapsRect
  • Manipulation:
    • cc.rectUnion
    • cc.rectIntersection

Bounding boxes and world co-ordinates

Intersection

Falling on top

Cocos-platform-fall-through.png

Example code

Cocos-jumper-platform.png

This is a sample Cocos2d-html5 project that has a jumper over a set of blocks. It implements simple physical movement and rectangular collision detection. View its source code at Bitbucket.