def __shrinkLoadingBar(self): if self.__isValidDownloadBar(): ivalDuration = 0.5 barPosIval = LerpPosInterval(self.bar, ivalDuration, (-0.81, 0, -0.96)) barScaleIval = LerpScaleInterval(self.bar, ivalDuration, (0.25, 0.25, 0.25)) def posText(pos): self.bar['text_pos'] = (0, pos) def scaleText(scale): self.bar['text_scale'] = (scale, scale) textScaleIval = LerpFunc(scaleText, fromData=0.08, toData=0.16, duration=ivalDuration) textPosIval = LerpFunc(posText, fromData=-0.035, toData=-0.05, duration=ivalDuration) shrinkIval = Parallel(barPosIval, barScaleIval, textPosIval, textScaleIval, Func(self.loadingText.hide)) self.hideBlockerIval = Sequence(shrinkIval, Wait(0.5), Func(self.__hideBlocker), Func(self.__resetLoadingBar), Func(self.destroy)) self.hideBlockerIval.start()
def append(self,text,width,height,spacing = 0, fadein = 0, fadeinType = 0): '''Add a NodePath that contains a generated text geom This method is called by SogalText ''' self.__lock.acquire() self.items.append(text) text.reparentTo(self) textPos = self.currentPtr text.setPos(textPos) if fadein: interval = Parallel() if fadeinType == 0 or fadeinType == 'normal': interval.append(LerpFunc(_modifyAlphaScale,fadein,0,1,blendType = 'easeOut',extraArgs = [text])) if fadeinType == 1 or fadeinType == 'flyin': interval.append(LerpFunc(_modifyAlphaScale,fadein,0,1,blendType = 'easeOut',extraArgs = [text])) interval.append(LerpPosInterval(text,fadein, self.currentPtr, (self.currentPtr[0],self.currentPtr[1],self.currentPtr[2] -0.3), blendType = 'easeOut')) interval.start() self.__lerpIntervals.append(interval) self.lineWidth = self.currentPtr[0] + width self.lineHeight = max(height, self.lineHeight) self.currentPtr = (self.lineWidth + spacing, 0, 0) self.__lock.release()
def __init__(self): self.current_animations = [] self.enterRunDuration = 1.5 self.enterWalkDuration = 0.5 self.skipPlayRateChanges = [self.IDLE] self.ease_in_idle = LerpFunc(self.easeAnimation, fromData=0, toData=1, blendType="easeIn", extraArgs=[self.IDLE]) self.ease_out_idle = LerpFunc(self.easeAnimation, fromData=1, toData=0, blendType="easeOut", extraArgs=[self.IDLE]) self.ease_in_walk = LerpFunc(self.easeAnimation, fromData=0, toData=1, duration=self.enterWalkDuration, blendType="noBlend", extraArgs=[self.WALK]) self.ease_out_walk = LerpFunc(self.easeAnimation, fromData=1, toData=0, blendType="noBlend", extraArgs=[self.WALK])
def loseGame(self, entry): # The triggers are set up so that the center of the ball should move to the # collision point to be in the hole global action action = "start" toPos = entry.getInteriorPoint(render) taskMgr.remove('rollTask') # Stop the maze task self.pathFollowed = np.zeros(self.pm.shape) self.maze.setP(0) self.maze.setR(0) # Move the ball into the hole over a short sequence of time. Then wait a # second and call start to reset the game Sequence( Parallel( LerpFunc(self.ballRoot.setX, fromData=self.ballRoot.getX(), toData=toPos.getX(), duration=.1), LerpFunc(self.ballRoot.setY, fromData=self.ballRoot.getY(), toData=toPos.getY(), duration=.1), LerpFunc(self.ballRoot.setZ, fromData=self.ballRoot.getZ(), toData=self.ballRoot.getZ() - .9, duration=.2)), Wait(1), Func(self.start)).start()
def poofBean(self, bean, beanAnim): if bean == None: self.notify.warning( 'poofBean, returning immediately as bean is None') return if bean.isEmpty(): self.notify.warning( 'poofBean, returning immediately as bean is empty') return currentAlpha = bean.getColorScale()[3] currentScale = bean.getScale() poofAnim = Sequence( Parallel( LerpFunc(bean.setAlphaScale, fromData=currentAlpha, toData=0.0, duration=0.25), LerpFunc(bean.setScale, fromData=currentScale, toData=currentScale * 5.0, duration=0.25)), Func(bean.stash), Func(beanAnim.finish), Func(bean.setAlphaScale, currentAlpha), Func(bean.setScale, currentScale)) poofAnim.start() return
def hide(self): if self.__hidden: return self.__hidden = True if not (self.__fading and self.__fadingDuration): NodePath.hide(self) self.removeFocus() if self.__mask: self.__mask.hide() if self.__bgPath: self.__bgPath.hide() if self.__hiddenFunc: self.__hiddenFunc(*self.__eventExtraArgs) else: #self.removeFocus() if self.__currentInterval: self.__currentInterval.pause() endpos = tuple( map(operator.add, self.__originPos, self.__fadingPositionOffset)) parallel = Parallel( LerpFunc(_modifyAlphaScale, self.__fadingDuration, 1, 0, blendType='easeIn', extraArgs=[self]), LerpPosInterval(self, self.__fadingDuration, endpos, self.__originPos, blendType='easeIn'), ) if self.__bgPath: parallel.append( LerpFunc(_modifyAlphaScale, self.__fadingDuration, 1, 0, blendType='easeIn', extraArgs=[self.__bgPath])) self.__currentInterval = Sequence( parallel, Func(NodePath.hide, self), Func(self.removeFocus), ) if self.__mask: self.__currentInterval.append(Func(self.__mask.hide)) if self.__bgPath: self.__currentInterval.append(Func(self.__bgPath.hide)) if self.__hiddenFunc: self.__currentInterval.append( Func(self.__hiddenFunc, *self.__eventExtraArgs)) self.__currentInterval.start()
def playMusic(self, music): curMusic = None nextMusic = None # get the current running music if self.musicAmbient.status() == self.musicAmbient.PLAYING: curMusic = self.musicAmbient if self.musicFight.status() == self.musicFight.PLAYING: curMusic = self.musicFight if self.musicGameOver.status() == self.musicGameOver.PLAYING: curMusic = self.musicGameOver # check which music we want to play next if music == "Fight": nextMusic = self.musicFight elif music == "Ambient": nextMusic = self.musicAmbient elif music == "GameOver": nextMusic = self.musicGameOver else: # stop all music self.musicFight.stop() self.musicAmbient.stop() self.musicGameOver.stop() fade = None if curMusic != None and nextMusic != None: # fade from cur to next # fade in the new music lerpAudioFadeOut = LerpFunc(self.audioFade, fromData=1, toData=0, duration=1.0, extraArgs=[curMusic]) lerpAudioFadeIn = LerpFunc(self.audioFade, fromData=0, toData=1, duration=1.0, extraArgs=[nextMusic]) fade = Sequence(lerpAudioFadeOut, Func(curMusic.stop), Func(nextMusic.play), lerpAudioFadeIn, name="FadeMusic") elif nextMusic != None: lerpAudioFadeIn = LerpFunc(self.audioFade, fromData=0, toData=1, duration=1.0, extraArgs=[nextMusic]) fade = Sequence(Func(nextMusic.play), lerpAudioFadeIn, name="FadeMusic") if fade != None: fade.start()
def show(self): if not self.__hidden: return self.__hidden = False if self.__mask or self.__bgPath: if self.__mask: self.__mask.reparentTo(aspect2d, sort=self.getSort()) self.__mask.show() if self.__bgPath: self.__bgPath.reparentTo(aspect2d, sort=self.getSort()) self.__bgPath.show() self.reparentTo(self.getParent(), sort=self.getSort()) if not (self.__fading and self.__fadingDuration): NodePath.show(self) self.requestFocus() if self.__shownFunc: self.__shownFunc(*self.__eventExtraArgs) else: NodePath.show(self) self.requestFocus() if self.__currentInterval: self.__currentInterval.pause() pos = tuple( map(operator.add, self.__originPos, self.__fadingPositionOffset)) parallel = Parallel( LerpFunc(_modifyAlphaScale, self.__fadingDuration, 0, 1, blendType='easeOut', extraArgs=[self]), LerpPosInterval(self, self.__fadingDuration, self.__originPos, pos, blendType='easeOut')) if self.__bgPath: parallel.append( LerpFunc(_modifyAlphaScale, self.__fadingDuration, 0, 1, blendType='easeOut', extraArgs=[self.__bgPath])) self.__currentInterval = Sequence(parallel) if self.__shownFunc: self.__currentInterval.append( Func(self.__shownFunc, *self.__eventExtraArgs)) self.__currentInterval.start()
def _initVisuals(self): RepairMincroGame._initVisuals(self) self.model = loader.loadModel('models/gui/pir_m_gui_srp_pumping_main') self.visual = self.attachNewNode('visual') self.visual.setPos(-0.25, 0.0, 0.074999999999999997) goalTopLoc = self.model.find('**/locator_top') goalTopLoc.reparentTo(self.visual) goalBottomLoc = self.model.find('**/locator_bottom') goalBottomLoc.reparentTo(self.visual) self.goalPositions = (goalBottomLoc.getPos(self), goalTopLoc.getPos(self)) self.greatLabel = DirectLabel(text = PLocalizer.Minigame_Repair_Pumping_Great, text_fg = (0.20000000000000001, 0.80000000000000004, 0.29999999999999999, 1.0), text_pos = (0.0, 0.59999999999999998), text_align = TextNode.ACenter, text_font = PiratesGlobals.getPirateFont(), relief = None, text_shadow = (0.0, 0.0, 0.0, 1.0), scale = (0.080000000000000002, 0.080000000000000002, 0.080000000000000002), pos = (-0.46500000000000002, 0.0, 0.0), parent = self) self.failLabel = DirectLabel(text = PLocalizer.Minigame_Repair_Pumping_Fail, text_fg = (0.80000000000000004, 0.20000000000000001, 0.29999999999999999, 1.0), text_pos = (0.0, 0.59999999999999998), text_align = TextNode.ARight, text_font = PiratesGlobals.getPirateFont(), text_shadow = (0.0, 0.0, 0.0, 1.0), relief = None, scale = (0.080000000000000002, 0.080000000000000002, 0.080000000000000002), pos = (-0.625, 0.0, 0.0), parent = self) self.shipBackground = self.model.find('**/static_ship_background') self.shipBackground.reparentTo(self.visual) self.waterMeter = self.model.find('**/sprite_waterBottom') self.waterMeter.reparentTo(self.visual) self.waterTop = self.model.find('**/sprite_waterTop') self.waterTop.reparentTo(self.visual) self.waterMeterTopLoc = self.waterMeter.find('**/locator_topOfShipWater') self.pumpBackground = self.model.find('**/pumpBackground') self.pumpBackground.reparentTo(self.visual) self.pumpWaterTop = self.model.find('**/sprite_pumpWaterTop') self.pumpWaterTop.reparentTo(self.visual) self.pumpWaterBottom = self.model.find('**/sprite_pumpWaterBottom') self.pumpWaterBottom.reparentTo(self.visual) self.pumpWaterTopLoc = self.pumpWaterBottom.find('**/locator_topOfPumpWater') self.pumpHandle = self.model.find('**/sprite_handle') self.pumpHandle.reparentTo(self.visual) self.pumpBar = self.model.find('**/static_pump') self.pumpBar.reparentTo(self.visual) self.goalBox = self.model.find('**/sprite_clickField') self.goalBox.reparentTo(self.visual) self.goalBox.setTransparency(1) self.enableGoalBox() self.pumpLine = self.model.find('**/sprite_bar') self.pumpLine.reparentTo(self.visual) self.ghostLine = self.visual.attachNewNode('ghostLine') self.pumpLine.getChild(0).copyTo(self.ghostLine) self.ghostLine.setScale(self.pumpLine.getScale()) self.ghostLine.setColor(1.0, 0.20000000000000001, 0.20000000000000001, 1.0) self.shipForground = self.model.find('**/static_ship_foreground') self.shipForground.reparentTo(self.visual) cm = CardMaker('cardMaker') cm.setFrame(-0.33000000000000002, 0.33000000000000002, 0.0, 1.0) self.goalBox.setZ(self.goalPositions[TOP].getZ()) self.goalBoxStartScale = self.goalBox.getSz() self.enableGoalBox() self.pumpWaterUpLerp = LerpFunc(self.setPumpWater, fromData = -0.10000000000000001, toData = 1.0, duration = 0.5) self.pumpWaterDownLerp = LerpFunc(self.setPumpWater, fromData = 1.0, toData = -0.10000000000000001, duration = 0.5) self.model.removeNode() del self.model
def lose_game(self, holeNP): toPos = holeNP.node().get_shape_pos(0) self.stop_game() Sequence( Parallel( LerpFunc(self.ballNP.set_x, fromData = self.ballNP.get_x(), toData = toPos.get_x(), duration = .1), LerpFunc(self.ballNP.set_y, fromData = self.ballNP.get_y(), toData = toPos.get_y(), duration = .1), LerpFunc(self.ballNP.set_z, fromData = self.ballNP.get_z(), toData = self.ballNP.get_z() - .9, duration = .2)), Wait(1), Func(self.start_game)).start()
def looseGame(self, holeNP): toPos = holeNP.node().getShapePos(0) self.stopGame() Sequence( Parallel( LerpFunc(self.ballNP.setX, fromData = self.ballNP.getX(), toData = toPos.getX(), duration = .1), LerpFunc(self.ballNP.setY, fromData = self.ballNP.getY(), toData = toPos.getY(), duration = .1), LerpFunc(self.ballNP.setZ, fromData = self.ballNP.getZ(), toData = self.ballNP.getZ() - .9, duration = .2)), Wait(1), Func(self.startGame)).start()
def fadeOut(self, element, time): """ Example updating RCSS attributes from code by modifying the 'color' RCSS attribute to slowly change from solid to transparent. element: the Rocket element whose style to modify time: time in seconds for fadeout """ # get the current color from RCSS effective style color = element.style.color # convert to RGBA form prefix = color[:color.rindex(',')+1].replace('rgb(', 'rgba(') def updateAlpha(t): # another way of setting style on a specific element attr = 'color: ' + prefix + str(int(t)) +');' element.SetAttribute('style', attr) alphaInterval = LerpFunc(updateAlpha, duration=time, fromData=255, toData=0, blendType='easeIn') return alphaInterval
def fadeOutLevel(self, fadeTime=1): """ the level-falls-apart animation. """ tiles = self.levelNode.findAllMatches("=Pos") for tile in tiles: x, y, z = self.getPosFromTile(tile) self.stopAnimatedTile(x, y, True) tile.setPos(x, y, 0) #tile.setHpr(random()*360,random()*360,random()*360) # seq = LerpPosHprInterval(tile,fadeTime+(0.3*fadeTime*random()),(x,y,-15),(random()*360 -180,random()*360-180,random()*360-180), blendType='easeIn') # seq.start() final_hpr = Vec3(random(), random(), random()) * 360.0 force = (Vec3(random(), random(), random()) - 0.5) * 5.0 force.z = 0 seq = LerpFunc(self.tileGravityAnimation, fromData=0, toData=1, duration=1.0, blendType='noBlend', extraArgs=[ tile.get_pos(render), Vec3(0), final_hpr, tile, force ]) tile.setPythonTag("Seq", seq) seq.start()
def contTunnel(self): # This line uses slices to take the front of the list and put it on the # back. For more information on slices check the Python manual self.tunnel = self.tunnel[1:] + self.tunnel[0:1] # Set the front segment (which was at TUNNEL_SEGMENT_LENGTH) to 0, which # is where the previous segment started self.tunnel[0].setZ(0) # Reparent the front to render to preserve the hierarchy outlined above self.tunnel[0].reparentTo(render) # Set the scale to be apropriate (since attributes like scale are # inherited, the rest of the segments have a scale of 1) self.tunnel[0].setScale(.155, .155, .305) # Set the new back to the values that the rest of teh segments have self.tunnel[3].reparentTo(self.tunnel[2]) self.tunnel[3].setZ(-TUNNEL_SEGMENT_LENGTH) self.tunnel[3].setScale(1) # Set up the tunnel to move one segment and then call contTunnel again # to make the tunnel move infinitely self.tunnelMove = Sequence( LerpFunc(self.tunnel[0].setZ, duration=TUNNEL_TIME, fromData=0, toData=TUNNEL_SEGMENT_LENGTH * .305), Func(self.contTunnel) ) self.tunnelMove.start()
def camera_lookat(self, position, rel=False, duration=2.0, proportional=True): new_rot, angle = self.camera.calc_look_at(position, rel) if settings.debug_jump: duration = 0 if duration == 0: self.camera.set_camera_rot(new_rot) else: if proportional: duration = duration * angle / pi if self.current_interval != None: self.current_interval.pause() self.current_interval = LerpFunc( self.do_camera_rot, fromData=0, toData=1, duration=duration, blendType='easeInOut', extraArgs=[ self.camera.get_camera_rot(), new_rot - self.camera.get_camera_rot() ], name=None) self.current_interval.start()
def move_and_rotate_camera_to(self, new_pos, new_rot, absolute=True, duration=0): if settings.debug_jump: duration = 0 if duration == 0: if absolute: self.camera.set_camera_pos(new_pos) self.camera.set_camera_rot(new_rot) else: self.camera.set_rel_camera_pos(new_pos) self.camera.set_rel_camera_rot(new_rot) else: if self.current_interval != None: self.current_interval.pause() self.fake = NodePath('fake') if absolute: self.start_pos = self.camera.get_rel_camera_pos() self.end_pos = self.camera.get_rel_position_of(new_pos) #TODO #new_rot = self.camera.get_rel_rotation_of(new_pos) nodepath_lerp = LerpQuatInterval(self.fake, duration=duration, blendType='easeInOut', quat = LQuaternion(*new_rot), startQuat = LQuaternion(*self.camera.get_camera_rot()) ) func_lerp = LerpFunc(self.do_camera_move_and_rot, fromData=0, toData=1, duration=duration, blendType='easeInOut', name=None) parallel = Parallel(nodepath_lerp, func_lerp) self.current_interval = parallel self.current_interval.start()
def turnLeft(self): #turns left initial = self.camAngle final = self.camAngle - math.pi/2 #turn animation turnTime = 0.2 turnRightSeq = Sequence() turnRightSeq.append(LerpFunc(self.changeCamAngle, turnTime, initial, final, 'easeInOut')) turnRightSeq.start() self.setKey("left", 1) #notes that left key is pressed #changes the direction left, based on current direction if self.direction == "N": self.direction = "W" elif self.direction == "W": self.direction = "S" elif self.direction == "S": self.direction = "E" else: self.direction = "N" #when you turn, all the collision disablements should be True #just checking #self.enableAllWalls() #update the label self.updateDirectionText()
def loadIntervals(self): def prepareHeightText(): self.heightText.node().setText(TTLocalizer.PartyTrampolineGetHeight % int(self.toon.getZ())) self.heightText.setZ(self.indicatorFactor * self.toon.getZ() + self.heightTextOffset) self.heightTextInterval = Sequence(Func(prepareHeightText), LerpFunc(self.heightText.setAlphaScale, fromData=1.0, toData=0.0, duration=1.0))
def __init__(self, whl_pos, whl_radius, car_h): GameObject.__init__(self) self.radius = whl_radius v_f = GeomVertexFormat.getV3() vdata = GeomVertexData('skid', v_f, Geom.UHDynamic) prim = GeomTriangles(Geom.UHStatic) self.vtx_cnt = 1 self.last_pos = whl_pos geom = Geom(vdata) geom.add_primitive(prim) self.node = GeomNode('gnode') self.node.add_geom(geom) nodepath = self.eng.gfx.root.attach_node(self.node) nodepath.set_transparency(True) nodepath.set_depth_offset(1) nodepath.node.set_two_sided(True) # for self-shadowing issues self.__set_material(nodepath) nodepath.p3dnode.set_bounds(OmniBoundingVolume()) self.add_vertices(whl_radius, car_h) self.add_vertices(whl_radius, car_h) def alpha(time, n_p): if not n_p.is_empty: n_p.node.set_shader_input('alpha', time) # this if seems necessary since, if there are skidmarks and you # exit from the race (e.g. back to the menu), then alpha is being # called from the interval manager even if the interval manager # correctly says that there are 0 intervals. self.remove_seq = Sequence( Wait(8), LerpFunc(alpha, 8, .5, 0, 'easeInOut', [nodepath]), Func(nodepath.remove_node)) self.remove_seq.start()
def __showSplat(self, position, direction, hot=False): if self.kaboomTrack is not None and self.kaboomTrack.isPlaying(): self.kaboomTrack.finish() self.clearHitInterval() splatName = 'splat-creampie' self.splat = globalPropPool.getProp(splatName) self.splat.setBillboardPointEye() self.splat.reparentTo(render) self.splat.setPos(self.root, position) self.splat.setAlphaScale(1.0) if not direction == 1.0: self.splat.setColorScale(PartyGlobals.CogActivitySplatColors[0]) if self.currentFacing > 0.0: facing = 'HitFront' else: facing = 'HitBack' else: self.splat.setColorScale(PartyGlobals.CogActivitySplatColors[1]) if self.currentFacing > 0.0: facing = 'HitBack' else: facing = 'HitFront' if hot: targetscale = 0.75 part = 'head' else: targetscale = 0.5 part = 'body' def setSplatAlpha(amount): self.splat.setAlphaScale(amount) self.hitInterval = Sequence( ActorInterval(self.actor, part + facing, loop=0), Func(self.actor.loop, 'idle')) self.hitInterval.start() self.kaboomTrack = Parallel( SoundInterval(self.pieHitSound, volume=1.0, node=self.actor, cutOff=PartyGlobals.PARTY_COG_CUTOFF), Sequence( Func(self.splat.showThrough), Parallel( Sequence( LerpScaleInterval(self.splat, duration=0.175, scale=targetscale, startScale=Point3(0.1, 0.1, 0.1), blendType='easeOut'), Wait(0.175)), Sequence( Wait(0.1), LerpFunc(setSplatAlpha, duration=1.0, fromData=1.0, toData=0.0, blendType='easeOut'))), Func(self.splat.cleanup), Func(self.splat.removeNode))) self.kaboomTrack.start() return
def fallAnimation(self, direction="down"): self.movement.disableControl() side_force = 1.7 if direction == "up": force = Vec3(-side_force, 0, 0) dest_hpr = Vec3(0, 0, -90) elif direction == "down": force = Vec3(side_force, 0, 0) dest_hpr = Vec3(0, 0, 90) elif direction == "left": force = Vec3(0, -side_force, 0) dest_hpr = Vec3(0, 90, 0) elif direction == "right": force = Vec3(0, side_force, 0) dest_hpr = Vec3(0, -90, 0) self.setAnimated(True) final_hpr = dest_hpr * 3.0 + Vec3(random(), random(), random()) * 360.0 * 0.0 anim = LerpFunc(self.animateCube, fromData=0, toData=1, duration=1.3, blendType='noBlend', extraArgs=[ self.cube.get_pos(render), Vec3(0), final_hpr, self.cube, force ]) anim.start()
def zoomOut(self): i = LerpFunc(self.setZoom, fromData=self.ZOOMLEVEL, toData=self.ZOOMLEVEL * 1.3, duration=1.0, blendType="easeInOut") i.start()
def enterDown(self): if self.oldState == 'Off': downAnimControl = self.actor.getAnimControl('down') self.actor.pose('down', downAnimControl.getNumFrames() - 1) return self.clearHitInterval() startScale = self.hole.getScale() endScale = Point3(5, 5, 5) self.hitInterval = Sequence( LerpFunc(self.setAlongSpline, duration=1.0, fromData=self.currentT, toData=0.0), LerpScaleInterval(self.hole, duration=0.175, scale=endScale, startScale=startScale, blendType='easeIn'), Parallel( SoundInterval(self.upSound, volume=0.6, node=self.actor, cutOff=PartyGlobals.PARTY_COG_CUTOFF), ActorInterval(self.actor, 'down', loop=0)), LerpScaleInterval(self.hole, duration=0.175, scale=Point3(3, 3, 3), startScale=endScale, blendType='easeOut')) self.hitInterval.start()
def __init__(self, wheel_pos, radius, heading): self.radius = radius v_f = GeomVertexFormat.getV3() self.vdata = GeomVertexData('skid', v_f, Geom.UHDynamic) self.vdata.setNumRows(1) self.vertex = GeomVertexWriter(self.vdata, 'vertex') self.prim = GeomTriangles(Geom.UHStatic) self.cnt = 1 self.last_pos = wheel_pos geom = Geom(self.vdata) geom.addPrimitive(self.prim) node = GeomNode('gnode') node.addGeom(geom) nodePath = render.attachNewNode(node) nodePath.setTransparency(True) nodePath.setDepthOffset(1) self.__set_material(nodePath) nodePath.node().setBounds(OmniBoundingVolume()) self.add_vertices(radius, heading) self.add_vertices(radius, heading) self.remove_seq = Sequence( Wait(8), LerpFunc(nodePath.setAlphaScale, 8, 1, 0, 'easeInOut'), Func(nodePath.remove_node)) self.remove_seq.start()
def stopMusic(self, time): if (self.isPlaying): i = LerpFunc(self.stopMusicLerp, fromData=1, toData=0, duration=time, blendType='noBlend', extraArgs=[], name=None).start()
def _hideFlashMessage( self, duration=0.0 ): if self.isDisabled(): assert self.notify.debug("_hideFlashMessage we're disabled, but still hiding self.flashText") # return self.flashTextInterval = Sequence(Wait( duration ), LerpFunc( self.flashText.setAlphaScale, fromData=1.0, toData=0.0, duration=1.0 ), Func( self.flashText.stash ),) self.flashTextInterval.start()
def loseGame(self, entry): toPos = entry.getInteriorPoint(render) taskMgr.remove("rollTask") Sequence( Parallel( LerpFunc(self.ballRoot.setX, fromData=self.ballRoot.getX(), toData=toPos.getX(), duration=0.1), LerpFunc(self.ballRoot.setY, fromData=self.ballRoot.getY(), toData=toPos.getY(), duration=0.1), LerpFunc(self.ballRoot.setZ, fromData=self.ballRoot.getZ(), toData=self.ballRoot.getZ() - .9, duration=0.2)), Wait(1), Func(self.start)).start()
def _hideFlashMessage(self, duration=0.0): if self.isDisabled(): pass self.flashTextInterval = Sequence( Wait(duration), LerpFunc(self.flashText.setAlphaScale, fromData=1.0, toData=0.0, duration=1.0), Func(self.flashText.stash)) self.flashTextInterval.start()
def set_sequence_params(self, **kwargs): """ update the p3d sequence to have a specific duration, extraArgs, and update function. This does not call the graphics update function afterwards automatically. The sequence will be (at first) only created and not restarted. Since a sequence's duration is determined on start time kwars: - duration: duration of the p3d sequence in seconds - extraArgs: extra arguments that the sequence update function receives - update_function: function with signature: (a : parameter in interval between 0 (beginning) and 1 (end), ) - on_finish_function """ create_lerp_and_seq = True if 'duration' in kwargs: self.state.duration = kwargs.get('duration') elif self.state.duration is None: print("Warning: LerpFunc will not be created yet, self.duration is None") create_lerp_and_seq = False if 'extraArgs' in kwargs: self.extraArgs = kwargs.get('extraArgs') elif self.extraArgs is None: print("Warning: LerpFunc will not be created yet, self.extraArgs is None") create_lerp_and_seq = False if 'update_function' in kwargs: self.update_function = kwargs.get('update_function') elif self.update_function is None: print("Warning: LerpFunc will not be created yet, self.update_function is None") create_lerp_and_seq = False if 'on_finish_function' in kwargs: self.on_finish_function = kwargs.get('on_finish_function') elif self.on_finish_function is None: # print("Warning: LerpFunc will not be created yet, self.on_finish_function is None") self.on_finish_function = lambda: None # create_lerp_and_seq = False if self.p3d_sequence: self.p3d_sequence.pause() # remove it from the interval manager del self.p3d_sequence # remove the reference if create_lerp_and_seq == True: self.p3d_interval = LerpFunc( self.update_function, duration=self.state.duration, extraArgs=self.extraArgs) self.p3d_sequence = direct.interval.IntervalGlobal.Sequence( self.p3d_interval, direct.interval.IntervalGlobal.Func(self.on_finish_function)) return self # in order to
def activate(self): lerp = LerpFunc( self.open_door, fromData=1, toData=0, duration=1, ) base.sequence_player.add_to_sequence(lerp) base.sequence_player.finalize() base.map.build(self.direction) self.open = True