本文整理汇总了Python中pandac.PandaModules.TextNode.setWordwrap方法的典型用法代码示例。如果您正苦于以下问题:Python TextNode.setWordwrap方法的具体用法?Python TextNode.setWordwrap怎么用?Python TextNode.setWordwrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.TextNode
的用法示例。
在下文中一共展示了TextNode.setWordwrap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: attachHostNameToSign
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
def attachHostNameToSign(self, locator):
if self.hostName == "":
return
nameText = TextNode("nameText")
nameText.setCardAsMargin(0.1, 0.1, 0.1, 0.1)
nameText.setCardDecal(True)
nameText.setCardColor(1.0, 1.0, 1.0, 0.0)
r = 232.0 / 255.0
g = 169.0 / 255.0
b = 23.0 / 255.0
nameText.setTextColor(r, g, b, 1)
nameText.setAlign(nameText.ACenter)
nameText.setFont(ToontownGlobals.getBuildingNametagFont())
nameText.setShadowColor(0, 0, 0, 1)
nameText.setBin("fixed")
if TTLocalizer.BuildingNametagShadow:
nameText.setShadow(*TTLocalizer.BuildingNametagShadow)
nameWordWrap = 11.0
nameText.setWordwrap(nameWordWrap)
scaleMult = 0.48
houseName = self.hostName
nameText.setText(houseName)
textWidth = nameText.getWidth()
xScale = 1.0 * scaleMult
if textWidth > nameWordWrap:
xScale = nameWordWrap / textWidth * scaleMult
sign_origin = locator
namePlate = sign_origin.attachNewNode(nameText)
namePlate.setDepthWrite(0)
namePlate.setPos(0, 0, 0)
namePlate.setScale(xScale)
示例2: addball
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
def addball(self, NUM):
X = "Person_pics/" + NUM + '.jpeg'
tex = loader.loadTexture(X)
f = loader.loadModel("models/ball1.egg")
f.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
a = random.uniform((-8 + (self.addx)), (8 + self.addx))
b = random.uniform((-8 + (self.addy)), (8 + self.addy))
c = random.uniform((-8 + (self.addz)), (8 + self.addz))
pos = Vec3(a,b,c)
f.setTexture(tex, 1)
f.setPos(pos)
f.setScale(.8)
f.reparentTo(render)
f.setCollideMask(0)
text = NUM
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath.setPos(a,b,(c + 0.6))
newTextNodePath.setColor(255, 0, 0,1)
newTextNodePath.setScale(.5)
return pos
示例3: loadSign
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
def loadSign(self):
actNameForSign = self.activityName
if self.activityId == PartyGlobals.ActivityIds.PartyJukebox40:
actNameForSign = PartyGlobals.ActivityIds.getString(PartyGlobals.ActivityIds.PartyJukebox)
elif self.activityId == PartyGlobals.ActivityIds.PartyDance20:
actNameForSign = PartyGlobals.ActivityIds.getString(PartyGlobals.ActivityIds.PartyDance)
self.sign = self.root.attachNewNode('%sSign' % self.activityName)
self.signModel = self.party.defaultSignModel.copyTo(self.sign)
self.signFlat = self.signModel.find('**/sign_flat')
self.signFlatWithNote = self.signModel.find('**/sign_withNote')
self.signTextLocator = self.signModel.find('**/signText_locator')
textureNodePath = getPartyActivityIcon(self.party.activityIconsModel, actNameForSign)
textureNodePath.setPos(0.0, -0.02, 2.2)
textureNodePath.setScale(2.35)
textureNodePath.copyTo(self.signFlat)
textureNodePath.copyTo(self.signFlatWithNote)
text = TextNode('noteText')
text.setTextColor(0.2, 0.1, 0.7, 1.0)
text.setAlign(TextNode.ACenter)
text.setFont(OTPGlobals.getInterfaceFont())
text.setWordwrap(10.0)
text.setText('')
self.noteText = self.signFlatWithNote.attachNewNode(text)
self.noteText.setPosHpr(self.signTextLocator, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0)
self.noteText.setScale(0.2)
self.signFlatWithNote.stash()
self.signTextLocator.stash()
示例4: addball
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
def addball(self, NUM):
#pos = Vec3(random.uniform(-7, 7), random.uniform(-7, 7), random.uniform(-7, 7))
a = random.uniform((-8 + (self.addx)), (8 + self.addx))
b = random.uniform((-8 + (self.addy)), (8 + self.addy))
c = random.uniform((-8 + (self.addz)), (8 + self.addz))
pos = Vec3(a,b,c)
f = loader.loadModel("models/ball")
f.setPos(pos)
f.setScale(.8)
f.reparentTo(render)
f.setCollideMask(0)
text = NUM
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath.setPos(a,b,(c + 0.6))
newTextNodePath.setColor(255, 0, 0,1)
newTextNodePath.setScale(2)
#self.V = self.V + 1
#self.negy = (10%(self.V))*(-7)
#self.posy = (10%(self.V)+3)*(-7)
return pos
示例5: addball
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
def addball(self, NUM):
# pos = Vec3(random.uniform(-7, 7), random.uniform(-7, 7), random.uniform(-7, 7))
if self.model == True and self.text == True:
self.f.remove()
self.newTextNodePath2.remove()
a = random.uniform(-7, 7)
b = random.uniform(-7, 7)
c = random.uniform(-7, 7)
pos = Vec3(a, b, c)
tex = loader.loadTexture("cra/textures/e.jpeg")
self.f = loader.loadModel("cra/models/ball1.egg")
self.f.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
self.f.setTexture(tex, 1)
self.f.setPos(pos)
self.f.setScale(1.5)
self.f.reparentTo(render)
self.f.setCollideMask(0)
text = NUM
newTextNode = TextNode("text") # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
self.newTextNodePath2 = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
self.newTextNodePath2.setPos(a, b, (c + 0.3))
self.newTextNodePath2.setColor(255, 0, 0, 1)
self.newTextNodePath2.setScale(0.6)
return pos
示例6: center
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
def center(self, prsn_name , m):
if (m < 5):
self.i = self.i + 1
X = 'Person_pics/' + prsn_name + '.jpeg'
tex = loader.loadTexture(X)
self.sphere = loader.loadModel("models/ball1")
self.sphere.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
self.sphere.setTexture(tex, 1)
self.sphere.reparentTo(render)
gx = self.sx
y = self.sy
z = self.sz
pos = (gx,y,z)
self.addx =gx
self.addy =y
self.addz =z
self.sphere.setPos(1, self.sy, 1)
self.sphere.setScale(.9)
self.sy = -14*(self.i)
else :
x = m/5
j = m%5
if ( j == 0):
self.sy = 1
self.i = 1
else :
self.sy = -14*(self.i)
self.sx = 40*(x)
self.sphere = loader.loadModel("models/ball1")
self.sphere.reparentTo(render)
gx = self.sx
y = self.sy
z = self.sz
self.addx =gx
self.addy =y
self.addz =z
pos = (gx, y, 1)
self.sphere.setPos(pos)
#self.sphere.setScale(.9)
self.i = self.i + 1
self.sphere.setScale(.9)
text = prsn_name
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath.setPos(gx, y, (z + 2))
newTextNodePath.setColor(0, 0, 255,1)
newTextNodePath.setScale(.5)
return pos
示例7: load
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
def load(self):
from toontown.toonbase import ToontownGlobals
from pandac.PandaModules import TextNode
textNode = TextNode('moviedialogue')
textNode.setTextColor(0, 0, 0, 1)
textNode.setCardColor(1, 1, 1, 1)
textNode.setCardAsMargin(0, 0, 0, 0)
textNode.setCardDecal(True)
textNode.setWordwrap(27.0)
textNode.setAlign(TextNode.ACenter)
textNode.setFont(ToontownGlobals.getToonFont())
self._dialogueLabel = aspect2d.attachNewNode(textNode)
self._dialogueLabel.setScale(0.06, 0.06, 0.06)
self._dialogueLabel.setPos(0.32, 0, -0.75)
self._dialogueLabel.reparentTo(hidden)
示例8: center
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
def center(self, prsn_name):
self.sphere = loader.loadModel("models/ball")
self.sphere.reparentTo(render)
self.sphere.setPos(1, 1, 1)
self.sphere.setScale(.9)
text = prsn_name
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath.setPos(1, 1, 2)
newTextNodePath.setColor(255, 0, 0,1)
newTextNodePath.setScale(.8)
示例9: centerF
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
def centerF(self, prsn_name):
if self.model == True and self.text == True:
self.sphere.remove()
self.newTextNodePath1.remove()
X = "cra/textures/" + prsn_name + ".jpeg"
tex = loader.loadTexture(X)
self.sphere = loader.loadModel("cra/models/ball1.egg")
self.sphere.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
self.sphere.setTexture(tex, 1)
self.sphere.reparentTo(render)
self.sphere.setPos(1, 1, 1)
self.sphere.setScale(2.5)
text = prsn_name
newTextNode = TextNode("text") # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
self.newTextNodePath1 = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
self.newTextNodePath1.setPos(1, 1, 2)
self.newTextNodePath1.setColor(255, 0, 0, 1)
self.newTextNodePath1.setScale(0.8)
示例10: PartyPlanner
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
#.........这里部分代码省略.........
def __exitPublic(self, mouseEvent):
self.publicDescriptionLabel.stash()
def __doTogglePublicPrivate(self):
if self.isPrivate:
self.isPrivate = False
self.privateButton['state'] = DirectGuiGlobals.NORMAL
self.publicButton['state'] = DirectGuiGlobals.DISABLED
else:
self.isPrivate = True
self.privateButton['state'] = DirectGuiGlobals.DISABLED
self.publicButton['state'] = DirectGuiGlobals.NORMAL
def _createPartyEditorPage(self):
page = DirectFrame(self.frame)
page.setName('PartyPlannerEditorPage')
self.LayoutTitleLabel = DirectLabel(parent=page, relief=None, text=TTLocalizer.PartyPlannerEditorTitle, pos=self.gui.find('**/title_locator').getPos() + Point3(0.0, 0.0, 0.075), scale=self.titleScale)
self.costLabel = DirectLabel(parent=page, pos=(-0.74, 0.0, 0.17), relief=None, text=TTLocalizer.PartyPlannerTotalCost % 0, text_align=TextNode.ACenter, scale=TTLocalizer.PPcostLabel, textMayChange=True)
self.partyGridBackground = DirectFrame(parent=page, relief=None, geom=self.gui.find('**/partyGrid_flat'))
self.partyGroundsLabel = DirectLabel(parent=page, relief=None, text=TTLocalizer.PartyPlannerPartyGrounds, text_font=ToontownGlobals.getSignFont(), text_fg=VBase4(1.0, 0.0, 0.0, 1.0), text_scale=TTLocalizer.PPpartyGroundsLabel, pos=self.gui.find('**/step_05_partyGrounds_text_locator').getPos(), scale=0.1)
self.activityBackground = DirectFrame(parent=page, relief=None, geom=self.gui.find('**/activitiesDecorations_flat1'), pos=(0.0, 0.0, 0.04))
pos = self.gui.find('**/step_05_instructions_locator').getPos()
self.instructionLabel = DirectLabel(parent=page, relief=None, text=' ', text_pos=(pos[0], pos[2]), text_scale=TTLocalizer.PPinstructionLabel, textMayChange=True, geom=self.gui.find('**/instructions_flat'))
self.elementTitleLabel = DirectLabel(parent=page, relief=None, text=' ', pos=self.gui.find('**/step_05_activitiesName_text_locator').getPos() + Point3(0.0, 0.0, 0.04), text_scale=TTLocalizer.PPelementTitleLabel, textMayChange=True)
self.elementPriceNode = TextNode('ElementPrice')
self.elementPriceNode.setAlign(TextNode.ALeft)
self.elementPriceNode.setTextColor(0.0, 0.0, 0.0, 1.0)
self.elementPriceNode.setFont(ToontownGlobals.getToonFont())
self.elementPrice = page.attachNewNode(self.elementPriceNode)
self.elementPrice.setScale(TTLocalizer.PPelementPriceNode)
self.elementPrice.setPos(self.gui.find('**/step_05_activityPrice_text_locator').getPos() + Point3(-0.02, 0.0, 0.04))
self.elementDescriptionNode = TextNode('ElementDescription')
self.elementDescriptionNode.setAlign(TextNode.ACenter)
self.elementDescriptionNode.setWordwrap(8)
self.elementDescriptionNode.setFont(ToontownGlobals.getToonFont())
self.elementDescriptionNode.setTextColor(0.0, 0.0, 0.0, 1.0)
self.elementDescription = page.attachNewNode(self.elementDescriptionNode)
self.elementDescription.setScale(TTLocalizer.PPelementDescription)
self.elementDescription.setPos(self.gui.find('**/step_05_activityDescription_text_locator').getPos() + Point3(0.0, 0.0, 0.04))
self.totalMoney = base.localAvatar.getTotalMoney()
catalogGui = loader.loadModel('phase_5.5/models/gui/catalog_gui')
self.beanBank = DirectLabel(parent=page, relief=None, text=str(self.totalMoney), text_align=TextNode.ARight, text_scale=0.075, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1), text_pos=(0.495, -0.53), text_font=ToontownGlobals.getSignFont(), textMayChange=True, image=catalogGui.find('**/bean_bank'), image_scale=(0.65, 0.65, 0.65), scale=0.9, pos=(-0.75, 0.0, 0.6))
catalogGui.removeNode()
del catalogGui
self.accept(localAvatar.uniqueName('moneyChange'), self.__moneyChange)
self.accept(localAvatar.uniqueName('bankMoneyChange'), self.__moneyChange)
self.partyEditor = PartyEditor(self, page)
self.partyEditor.request('Hidden')
pos = self.gui.find('**/step_05_add_text_locator').getPos()
self.elementBuyButton = DirectButton(parent=page, relief=None, text=TTLocalizer.PartyPlannerBuy, text_pos=(pos[0], pos[2]), text_scale=TTLocalizer.PPelementBuyButton, geom=(self.gui.find('**/add_up'), self.gui.find('**/add_down'), self.gui.find('**/add_rollover')), geom3_color=VBase4(0.5, 0.5, 0.5, 1.0), textMayChange=True, pos=(0.0, 0.0, 0.04), command=self.partyEditor.buyCurrentElement)
self.okWithPartyGroundsLayoutEvent = 'okWithPartyGroundsLayoutEvent'
self.accept(self.okWithPartyGroundsLayoutEvent, self.okWithPartyGroundsLayout)
self.okWithGroundsGui = TTDialog.TTGlobalDialog(dialogName=self.uniqueName('PartyEditorOkGui'), doneEvent=self.okWithPartyGroundsLayoutEvent, message=TTLocalizer.PartyPlannerOkWithGroundsLayout, style=TTDialog.YesNo, okButtonText=OTPLocalizer.DialogYes, cancelButtonText=OTPLocalizer.DialogNo)
self.okWithGroundsGui.doneStatus = ''
self.okWithGroundsGui.hide()
return page
def okWithPartyGroundsLayout(self):
self.okWithGroundsGui.hide()
if self.okWithGroundsGui.doneStatus == 'ok':
self.__nextItem()
def setNextButtonState(self, enabled):
if enabled:
self.nextButton['state'] = DirectGuiGlobals.NORMAL
self.nextButton.show()
示例11: gameGUI
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
class gameGUI(DirectObject):
def __init__(self):
self.points = 0
self.timersecs = 60
self.duration = 0
self.ncandy = 0
self.runralph = 0
self.gamepause = 0
self.picked = 0
self.bg = loader.loadSfx("./sounds/faster_than_all.ogg")
self.bg.setLoop(True)
self.bg.setVolume(0.3)
self.bgcount = loader.loadSfx("./sounds/panic.ogg")
self.bgcount.setLoop(False)
self.bgcount.setVolume(1)
self.playBG()
butaicon = OnscreenImage(image = './GUI/smiley1.png', pos = (0.66, 0, 0.85))
butaicon.setScale(0.12,0,0.11)
butaicon.setTransparency(TransparencyAttrib.MAlpha)
tpButa = TextProperties()
tpButa.setTextColor(1,1,1,1)
butafont = loader.loadFont('./GUI/fonts/butafont.ttf')
tpButa.setFont(butafont)
tpButa.setShadow(0.05, 0.05)
tpButa.setShadowColor(0,0,0,1)
tpMgr = TextPropertiesManager.getGlobalPtr()
tpMgr.setProperties("buta", tpButa)
tpMenu = TextProperties()
tpMenu.setTextColor(1,0.6,0.75,1)
tpMenu.setFont(butafont)
tpMenu.setShadow(0.05, 0.05)
tpMenu.setShadowColor(1,0.8,0.9,1)
tpMgr.setProperties("menu", tpMenu)
#Add candy number
self.candy = TextNode('Candy Number')
self.candy.setText("\1buta\1x "+str(self.ncandy)+" \2")
self.candynumNP = aspect2d.attachNewNode(self.candy)
self.candynumNP.setScale(0.18)
self.candynumNP.setPos(0.79, 0, 0.8)
#Add points number
self.ptnum = TextNode('Pt Number')
self.ptnum.setText("\1buta\1Pt. "+str(self.points)+" \2")
self.ptnumNP = aspect2d.attachNewNode(self.ptnum)
self.ptnumNP.setScale(0.18)
self.ptnumNP.setPos(-1.31, 0, 0.8)
#Add record number
recordfile = open("candyrecord.dat","r")
self.record = int(recordfile.read())
recordfile.close()
self.rcnum = TextNode('Record Number')
self.rcnum.setText("\1buta\1Record \n"+str(self.record)+" \2")
self.rcnumNP = aspect2d.attachNewNode(self.rcnum)
self.rcnumNP.setScale(0.11)
self.rcnumNP.setPos(-1.38, 0, 0.65)
self.rcnum.setWordwrap(4.5)
#Add timer
self.timer = TextNode('Timer')
self.timer.setText("\1buta\1 "+str(self.timersecs/60)+":00 \2")
self.timerNP = aspect2d.attachNewNode(self.timer)
self.timerNP.setScale(0.18)
self.timerNP.setPos(0.9,0,-0.93)
self.itemset = {"musicon":loader.loadTexture('./GUI/soundon.png'),"musicoff":loader.loadTexture('./GUI/soundoff.png'),}
self.itembox = DirectButton(image=self.itemset["musicon"], scale=.10, pos=(-1.19,0,-0.82), relief=None, state=DGG.NORMAL, command=self.changemusic, clickSound=None)
self.itembox.setScale(0.15)
self.itembox.setTransparency(TransparencyAttrib.MAlpha)
def controls(self):
self.controlsleft = TextNode('controlsleft')
self.controlsleft.setText("\1buta\1J-Left \2")
self.controlsleftNP = aspect2d.attachNewNode(self.controlsleft)
self.controlsleftNP.setScale(0.07)
self.controlsleftNP.setPos(-1.38, 0, 0.31)
self.controlsforward = TextNode('controlsforward')
self.controlsforward.setText("\1buta\1I-Forward \2")
self.controlsforwardNP = aspect2d.attachNewNode(self.controlsforward)
self.controlsforwardNP.setScale(0.07)
self.controlsforwardNP.setPos(-1.38, 0, 0.20)
self.controlsright = TextNode('controlsright')
self.controlsright.setText("\1buta\1L-Right \2")
self.controlsrightNP = aspect2d.attachNewNode(self.controlsright)
self.controlsrightNP.setScale(0.07)
self.controlsrightNP.setPos(-1.38, 0, 0.11)
self.controlscameraa = TextNode('controlscameraa')
self.controlscameraa.setText("\1buta\1A-Rotate camera left \2")
self.controlscameraaNP = aspect2d.attachNewNode(self.controlscameraa)
self.controlscameraaNP.setScale(0.07)
#.........这里部分代码省略.........
示例12: center
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
def center(self, prsn_name , m):
if (m < 5):
#creating the card without glow map
cardMaker = CardMaker("cubemaker")
card = render.attachNewNode(cardMaker.generate())
#base.saveSphereMap('k.jpeg', size = 256)
#tex = loader.loadTexture('k.jpeg')
#card.setTexture(tex)
card.setDepthWrite(True)
card.setTransparency(True)
self.sphere = loader.loadModel("models/ball")
self.sphere.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
#self.sphere.setTexture(tex, 1)
self.sphere.reparentTo(render)
self.sphere.setPos(1, 1, 1)
self.sphere.setScale(2.5)
self.i = self.i + 1
gx = self.sx
y = self.sy
z = self.sz
pos = (gx,y,z)
self.addx =gx
self.addy =y
self.addz =z
self.sphere.setPos(1, self.sy, 1)
self.sphere.setScale(1)
self.sy = -14*(self.i)
else :
x = m/5
j = m%5
if ( j == 0):
self.sy = 1
self.i = 1
else :
self.sy = -14*(self.i)
self.sx = 40*(x)
self.sphere = loader.loadModel("models/ball")
self.sphere.reparentTo(render)
gx = self.sx
y = self.sy
z = self.sz
self.addx =gx
self.addy =y
self.addz =z
pos = (gx, y, 1)
self.sphere.setPos(pos)
#self.sphere.setScale(.9)
self.i = self.i + 1
self.sphere.setScale(1)
text = prsn_name
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath.setPos(gx, y, (z + 2))
newTextNodePath.setColor(0, 0, 255,1)
newTextNodePath.setScale(2)
return pos
示例13: __init__
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
class Nametag:
TEXT_WORD_WRAP = 8
TEXT_Y_OFFSET = -0.05
CHAT_TEXT_WORD_WRAP = 12
PANEL_X_PADDING = 0.2
PANEL_Z_PADDING = 0.2
CHAT_BALLOON_ALPHA = 1
def __init__(self):
self.avatar = None
self.panel = None
self.icon = None
self.chatBalloon = None
self.chatButton = NametagGlobals.noButton
self.chatReversed = False
self.font = None
self.chatFont = None
self.chatType = NametagGlobals.CHAT
self.chatBalloonType = NametagGlobals.CHAT_BALLOON
self.nametagColor = NametagGlobals.NametagColors[NametagGlobals.CCNormal]
self.chatColor = NametagGlobals.ChatColors[NametagGlobals.CCNormal]
self.speedChatColor = self.chatColor[0][1]
self.nametagHidden = False
self.chatHidden = False
self.thoughtHidden = False
# Create our TextNodes:
self.textNode = TextNode('text')
self.textNode.setWordwrap(self.TEXT_WORD_WRAP)
self.textNode.setAlign(TextNode.ACenter)
self.chatTextNode = TextNode('chatText')
self.chatTextNode.setWordwrap(self.CHAT_TEXT_WORD_WRAP)
self.chatTextNode.setGlyphScale(ChatBalloon.TEXT_GLYPH_SCALE)
self.chatTextNode.setGlyphShift(ChatBalloon.TEXT_GLYPH_SHIFT)
# Add the tick task:
self.tickTaskName = self.getUniqueName() + '-tick'
self.tickTask = taskMgr.add(self.tick, self.tickTaskName, sort=45)
def destroy(self):
if self.tickTask is not None:
taskMgr.remove(self.tickTask)
self.tickTask = None
self.chatTextNode = None
self.textNode = None
self.chatFont = None
self.font = None
self.chatButton = NametagGlobals.noButton
self.removeBalloon()
self.removeIcon()
self.removePanel()
self.avatar = None
def getUniqueName(self):
return 'Nametag-' + str(id(self))
def getChatBalloonModel(self):
pass # Inheritors should override this method.
def getChatBalloonWidth(self):
pass # Inheritors should override this method.
def getChatBalloonHeight(self):
pass # Inheritors should override this method.
def tick(self, task):
return Task.done # Inheritors should override this method.
def updateClickRegion(self):
pass # Inheritors should override this method.
def drawChatBalloon(self, model, modelWidth, modelHeight):
pass # Inheritors should override this method.
def drawNametag(self):
pass # Inheritors should override this method.
def setAvatar(self, avatar):
self.avatar = avatar
def getAvatar(self):
return self.avatar
def setIcon(self, icon):
self.icon = icon
#.........这里部分代码省略.........
示例14: Game
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
#.........这里部分代码省略.........
self.setupTargeting()
#seed the random number generator
random.seed()
# configure the entire GUI
self.setupGUI()
# configure the title screen
self.setupTitleScreen()
def setupGUI(self):
GUIFont = loader.loadFont(FONTS_PATH + 'orbitron-medium.ttf')
"""
self.debugText = TextNode('debug')
self.debugText.setText("")
self.debugText.setAlign(TextNode.ALeft)
self.debugText.setFont(GUIFont)
dTextNodePath = aspect2d.attachNewNode(self.debugText)
dTextNodePath.setScale(0.075)
dTextNodePath.setPos(-1.2, 0, -0.9)
"""
#INTRO
self.introText = TextNode('intro')
self.introText.setText("")
self.introText.setAlign(TextNode.ALeft)
self.introText.setFont(GUIFont)
self.introText.setCardColor(0.1, 0.1, 0.1, 0.6)
self.introText.setCardAsMargin(0.5, 0.5, 0.5, 0.5)
self.introText.setCardDecal(True)
self.introText.setWordwrap(30.0)
self.iTextNodePath = aspect2d.attachNewNode(self.introText)
self.iTextNodePath.setScale(0.06)
self.iTextNodePath.setPos(-1.2, 0, -0.7)
#image is 171 x 323
self.leftMouseImage = OnscreenImage()
self.leftMouseImage.setImage(GUI_PATH + "mouse-icon-left.png")
self.leftMouseImage.setTransparency(1)
self.leftMousePath = aspect2d.attachNewNode(self.leftMouseImage.node())
self.rightMouseImage = OnscreenImage()
self.rightMouseImage.setImage(GUI_PATH + "mouse-icon-right.png")
self.rightMouseImage.setTransparency(1)
self.rightMousePath = aspect2d.attachNewNode(self.rightMouseImage.node())
self.middleMouseImage = OnscreenImage()
self.middleMouseImage.setImage(GUI_PATH + "mouse-icon-middle.png")
self.middleMouseImage.setTransparency(1)
self.middleMousePath = aspect2d.attachNewNode(self.middleMouseImage.node())
self.leftMousePath.setScale(.105882, 0, .2)
self.leftMousePath.setPos(1.1, 0, -0.75)
self.rightMousePath.setScale(.105882, 0, .2)
self.rightMousePath.setPos(1.1, 0, -0.75)
self.middleMousePath.setScale(.105882, 0, .2)
self.middleMousePath.setPos(1.1, 0, -0.75)
self.leftMousePath.hide()
self.rightMousePath.hide()
self.middleMousePath.hide()
示例15: TextBoard
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setWordwrap [as 别名]
class TextBoard():
def __init__(self, text_color=(1,1,1), max_nr_rows=3, nr_char_per_row=20,
frame_color=(0,0,0), frame_padding=0.4, frame_line_width=2,
background_color=(1,1,0), background_padding=0.8):
#print "TextBoard::init"
# everything that belongs to this TextBoard will be stored under the root node
self.root_node_path = render.attachNewNode(PandaNode(''))
# create the text node that will be the TextBoard
self.text_node = TextNode('')
self.text_node_path = self.root_node_path.attachNewNode(self.text_node)
self.set_max_nr_rows(max_nr_rows)
r,g,b = text_color
self.set_text_color(r, g, b)
self.text_node.setAlign(TextNode.ALeft) # TextNode.ALeft, TextNode.ACenterba
letter_width, letter_height = self._compute_letter_size()
self.max_row_length = nr_char_per_row * letter_width
self.text_node.setWordwrap(self.max_row_length)
width, height = self._compute_max_text_size()
self.text_node_path.setPos(0.5*background_padding,-0.01,-letter_height)
self.background_node_path = self.root_node_path.attachNewNode(PandaNode('background_node'))
self._create_background(self.background_node_path, width+background_padding, height+background_padding+letter_height)
self.frame_node_path = self.root_node_path.attachNewNode(PandaNode('frame_node'))
self._create_frame(self.frame_node_path, width+background_padding, height+background_padding+letter_height)
r,g,b = frame_color
self.set_frame_color(r, g, b)
self.set_frame_line_width(frame_line_width)
r,g,b = background_color
self.set_background_color(r, g, b)
def _compute_max_text_size(self):
self.text_node.setText(' ')
width = 0
while (not self.text_node.getWidth() == width) and self.text_node.getWidth() < self.max_row_length:
width = self.text_node.getWidth()
self.text_node.appendText(' ')
while self.text_node.getNumRows() < self.text_node.getMaxRows():
self.text_node.appendText('\n')
return self.text_node.getWidth(), self.text_node.getHeight()
def _compute_letter_size(self):
self.text_node.setText('W')
return self.text_node.getWidth(), self.text_node.getHeight()
def _create_background(self, root_node_path, width, height):
node, _vdata = create_side((0,0), (width, -height))
root_node_path.attachNewNode(node)
def _create_frame(self, root_node_path, width, height):
# top
node, _vdata = create_line(0, 0, width, 0)
root_node_path.attachNewNode(node)
# right side
node, _vdata = create_line(width, 0, width, -height)
root_node_path.attachNewNode(node)
# bottom side
node, _vdata = create_line(width, -height, 0, -height)
root_node_path.attachNewNode(node)
# right side
node, _vdata = create_line(0, -height, 0, 0)
root_node_path.attachNewNode(node)
def get_node_path(self):
return self.root_node_path
def set_scale(self, scale):
self.root_node_path.setScale(scale)
def set_center_pos_xz(self, x, z):
self.set_center_pos(x, 0, z)
def set_center_pos(self, x, y, z):
width, height = get_bounding_width_height(self.get_node_path())
self.get_node_path().setPos(x-width/2.0, y, z+height/2.0)
def set_text(self, text=''):
self.text_node.clearText()
self.text_node.setText(text)
def set_text_color(self, r, g, b, alpha=1):
self.text_node.setTextColor(r,g,b,alpha)
def set_max_nr_rows(self, n):
self.text_node.setMaxRows(n)
def set_frame_visible(self, visible):
rgba = self.frame_node_path.getColor()
r = rgba[0]
g = rgba[1]
b = rgba[2]
if visible:
alpha = 1
else:
alpha = 0
self.frame_node_path.setColor(r, g, b, alpha)
def set_frame_color(self, r, g, b, alpha=1):
self.frame_node_path.setColor(r, g, b, alpha)
#.........这里部分代码省略.........