对这个例程的介绍有点深意,说是通过碰撞检测机制来操作鼠标控制棋盘,但是又说Plane类可以更快的实现。不知道这个Plane类是啥,但是先研究下这个例程本身好了。
self.disableMouse()先说一下这个方法在之前每个例程里都有提到,之前觉得没什么,今天把这个注释掉后发现问题很大。
它的作用不是禁用鼠标,而是禁用默认的鼠标控制camera的功能。
1. 碰撞检测机制
from panda3d.core import CollisionHandlerQueue, CollisionRay
首先导入这两个包
Examples:
nodePath.setCollideMask(BitMask32(0x10))
This sets the into collide mask of nodePath, and all children of nodePath, to the value 0x10, regardless of the value each node had before.
nodePath.node().setFromCollideMask(BitMask32(0x10))
You can only set the from collide mask on a collision node, and you must set it directly on the node itself, not on the NodePath.
这两句的区别就在于一个是作为into对象,一个作为from对象。但看了例程之后 发现如果是into对象,是这样的语句:
self.squares[i].find("**/polygon").node().setIntoCollideMask(BitMask32.bit(1))
我觉得还是按例程来做即可了。
Thi