本文整理汇总了Python中panda3d.core.CollisionHandlerEvent.setOutPattern方法的典型用法代码示例。如果您正苦于以下问题:Python CollisionHandlerEvent.setOutPattern方法的具体用法?Python CollisionHandlerEvent.setOutPattern怎么用?Python CollisionHandlerEvent.setOutPattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.CollisionHandlerEvent
的用法示例。
在下文中一共展示了CollisionHandlerEvent.setOutPattern方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buildCollisions
# 需要导入模块: from panda3d.core import CollisionHandlerEvent [as 别名]
# 或者: from panda3d.core.CollisionHandlerEvent import setOutPattern [as 别名]
def buildCollisions(self):
TrapGag.buildCollisions(self)
gagSph = CollisionSphere(0, 0, 0, 1)
gagSph.setTangible(0)
gagNode = CollisionNode('gagSensor')
gagNode.addSolid(gagSph)
gagNP = self.gag.attachNewNode(gagNode)
gagNP.setScale(0.75, 0.8, 0.75)
gagNP.setPos(0.0, 0.1, 0.5)
gagNP.setCollideMask(BitMask32.bit(0))
gagNP.node().setFromCollideMask(CIGlobals.FloorBitmask)
event = CollisionHandlerEvent()
event.setInPattern('%fn-into')
event.setOutPattern('%fn-out')
base.cTrav.addCollider(gagNP, event)
示例2: BounceCheckAttack
# 需要导入模块: from panda3d.core import CollisionHandlerEvent [as 别名]
# 或者: from panda3d.core.CollisionHandlerEvent import setOutPattern [as 别名]
class BounceCheckAttack(ThrowAttack):
notify = directNotify.newCategory('BounceCheckAttack')
MaxBounces = 3
WeaponHitDistance = 0.5
def __init__(self, attacksClass, suit):
ThrowAttack.__init__(self, attacksClass, suit)
self.attack = 'bouncecheck'
self.bounceSound = None
self.numBounces = 0
return
def __pollCheckDistance(self, task):
if base.localAvatar.getDistance(self.weapon) <= self.WeaponHitDistance:
self.handleWeaponCollision(None)
return Task.done
else:
return Task.cont
return
def loadAttack(self):
self.weapon = loader.loadModel('phase_5/models/props/bounced-check.bam')
self.weapon.setScale(10)
self.weapon.setTwoSided(1)
self.bounceSound = base.audio3d.loadSfx('phase_5/audio/sfx/SA_bounce_check_bounce.mp3')
base.audio3d.attachSoundToObject(self.bounceSound, self.suit)
cSphere = CollisionSphere(0, 0, 0, 0.1)
cSphere.setTangible(0)
if hasattr(self, 'uniqueName'):
name = self.uniqueName('bounced_check_collision')
else:
name = 'bounced_check_collision'
cNode = CollisionNode(name)
cNode.addSolid(cSphere)
cNode.setFromCollideMask(CIGlobals.FloorBitmask)
cNP = self.weapon.attachNewNode(cNode)
cNP.setCollideMask(BitMask32(0))
self.event = CollisionHandlerEvent()
self.event.setInPattern('%fn-into')
self.event.setOutPattern('%fn-out')
base.cTrav.addCollider(cNP, self.event)
self.wsnp = cNP
self.wsnp.show()
def doAttack(self, ts = 0):
ThrowAttack.doAttack(self, ts)
self.loadAttack()
if hasattr(self, 'uniqueName'):
name = self.uniqueName('doBounceCheckAttack')
else:
name = 'doBounceCheckAttack'
self.suitTrack = Sequence(name=name)
self.weapon.reparentTo(self.suit.find('**/joint_Rhold'))
if self.suit.type == 'C':
self.suitTrack.append(Wait(2.3))
else:
self.suitTrack.append(Wait(3))
self.suit.play('throw-paper')
self.suitTrack.append(Func(self.throwObject))
self.suitTrack.start(ts)
def throwObject(self):
ThrowAttack.throwObject(self)
taskMgr.add(self.__pollCheckDistance, 'pollCheckDistance')
self.__doThrow(0)
def __doThrow(self, alreadyThrown):
self.weapon.setScale(1)
pathNP = NodePath('throwPath')
if not alreadyThrown:
pathNP.reparentTo(self.suit)
else:
pathNP.reparentTo(self.weapon)
pathNP.setScale(render, 1.0)
pathNP.setPos(0, 30, -100)
pathNP.setHpr(90, -90, 90)
print pathNP.getPos(base.render)
if self.throwTrajectory:
self.throwTrajectory.pause()
self.throwTrajectory = None
if alreadyThrown:
startPos = self.weapon.getPos(base.render)
gravity = 0.7
else:
gravity = 0.7
startPos = self.suit.find('**/joint_Rhold').getPos(base.render)
self.throwTrajectory = ProjectileInterval(self.weapon, startPos=startPos, endPos=pathNP.getPos(base.render), gravityMult=gravity, duration=3.0)
self.throwTrajectory.start()
self.weapon.setScale(10)
self.weapon.reparentTo(render)
self.weapon.setHpr(pathNP.getHpr(render))
self.weapon_state = 'released'
self.acceptOnce(self.wsnp.node().getName() + '-into', self.__handleHitFloor)
return
def __handleHitFloor(self, entry):
self.numBounces += 1
if self.numBounces >= self.MaxBounces:
self.cleanup()
return
#.........这里部分代码省略.........
示例3: CameraShyFirstPerson
# 需要导入模块: from panda3d.core import CollisionHandlerEvent [as 别名]
# 或者: from panda3d.core.CollisionHandlerEvent import setOutPattern [as 别名]
#.........这里部分代码省略.........
return
def __handleRayInto(self, entry):
intoNP = entry.getIntoNodePath()
toonNP = intoNP.getParent()
for key in base.cr.doId2do.keys():
obj = base.cr.doId2do[key]
if obj.__class__.__name__ == 'DistributedToon':
if obj.getKey() == toonNP.getKey():
self.__handleToonInFocus(obj)
def __handleRayOut(self, entry):
intoNP = entry.getIntoNodePath()
toonNP = intoNP.getParent()
for key in base.cr.doId2do.keys():
obj = base.cr.doId2do[key]
if obj.__class__.__name__ == 'DistributedToon':
if obj.getKey() == toonNP.getKey():
self.toonToTakePicOf = None
self.hasToonInFocus = False
if self.cameraFocus.getColorScale() == self.toonInFocusColor:
self.cameraFocus.setColorScale(self.toonOutOfFocusColor)
return
def __handleToonInFocus(self, toon):
if not self.hasToonInFocus or self.toonToTakePicOf is not None or self.toonToTakePicOf.doId != toon.doId:
self.toonToTakePicOf = toon
self.hasToonInFocus = True
self.cameraFocus.setColorScale(self.toonInFocusColor)
return
def start(self):
self.fullyChargedSound = base.loadSfx('phase_4/audio/sfx/MG_pairing_match.mp3')
self.rechargeSound = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_blue_arrow.mp3')
self.batteryFrame = DirectFrame(parent=base.a2dBottomRight, pos=(-0.2, 0, 0.1), scale=(0.8, 0, 1))
self.batteryBg = OnscreenImage(image='phase_4/maps/battery_charge_frame.png', parent=self.batteryFrame)
self.batteryBg.setTransparency(1)
self.batteryBg.setX(0.03)
self.batteryBg.setScale(0.17, 0, 0.05)
self.batteryBar = DirectWaitBar(value=0, range=5, barColor=(1, 1, 1, 1), relief=None, scale=(0.12, 0.0, 0.3), parent=self.batteryFrame)
self.cameraFocus = loader.loadModel('phase_4/models/minigames/photo_game_viewfinder.bam')
self.cameraFocus.reparentTo(base.aspect2d)
self.focusCollHandler = CollisionHandlerEvent()
self.focusCollHandler.setInPattern('%fn-into')
self.focusCollHandler.setOutPattern('%fn-out')
self.focusCollNode = CollisionNode('mouseRay')
self.focusCollNP = base.camera.attachNewNode(self.focusCollNode)
self.focusCollNode.setCollideMask(BitMask32(0))
self.focusCollNode.setFromCollideMask(CIGlobals.WallBitmask)
self.focusRay = CollisionRay()
self.focusRay.setFromLens(base.camNode, 0.0, 0.0)
self.focusCollNode.addSolid(self.focusRay)
base.cTrav.addCollider(self.focusCollNP, self.focusCollHandler)
base.localAvatar.walkControls.setWalkSpeed(CIGlobals.ToonForwardSpeed, 0.0, CIGlobals.ToonReverseSpeed, CIGlobals.ToonRotateSpeed)
FirstPerson.start(self)
return
def reallyStart(self):
self.accept('mouseRay-into', self.__handleRayInto)
self.accept('mouseRay-out', self.__handleRayOut)
self.camFSM.request('recharge')
taskMgr.add(self.movementTask, 'movementTask')
FirstPerson.reallyStart(self)
def end(self):
self.camFSM.request('off')
taskMgr.remove('movementTask')
self.ignore('mouseRay-into')
self.ignore('mouseRay-out')
FirstPerson.end(self)
def reallyEnd(self):
self.batteryBar.destroy()
self.batteryBar = None
self.batteryBg.destroy()
self.batteryBg = None
self.batteryFrame.destroy()
self.batteryFrame = None
self.cameraFocus.removeNode()
self.cameraFocus = None
self.focusCollHandler = None
self.focusCollNode = None
self.focusCollNP.removeNode()
self.focusCollNP = None
self.focusRay = None
self.hasToonInFocus = None
self.toonToTakePicOf = None
self.fullyChargedSound = None
self.rechargeSound = None
self.stopCameraFlash()
FirstPerson.reallyEnd(self)
base.localAvatar.walkControls.setWalkSpeed(CIGlobals.ToonForwardSpeed, CIGlobals.ToonJumpForce, CIGlobals.ToonReverseSpeed, CIGlobals.ToonRotateSpeed)
return
def cleanup(self):
self.camFSM.requestFinalState()
self.camFSM = None
FirstPerson.cleanup(self)
return