Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I wanted to make a "3D text" in my game. And I've decided to add "special symbols". For example, 'smile'. To get this symbol, it needs to be in text as '<smile>' to appear. Example: HUD_Message ("I'm happy!<smile>", 1) //text, scale Problem is, when I tried it with two symbols, I got an error, saying 'out of memory'. Even worse - in some cases the game just froze, not responding. Regular text works fine, but, is it because of those symbols at the start and end? Detection for those symbols looks like this: for (var k = 0; k < text.length; k++)Am I doing something wrong? Not that I'd be surprized, but, whatever... |
||||
|
I am not totally sure, but if K is negative then I think it will go in an infinite loop, or out of bound and might result in a memory overflow causing an out of memory error. You can do some extra checks to ensure that index is not out of bound or -1. and ">" is found. Though I am not sure if that's the case. |
||||
|
Okay, seems like you were close enough. I tried looking through 'k' value (value on each loop), and, well, I found the problem. Only, it's not that it's negative. It's that 'end' is always the same number. One thing I forgot to mention here is that, at the end of cycle, 'k' is being set to 'end' value. That means, infinite loop, as you've said. Fixed it by adding starting point to 'indexOf': end = text.indexOf ('>', k) - 1;Guess I shouldn't do programming late at night... Regardless, thanks for help. |
||||
|
Hi Dekon, You could probably simplify the flow a lot by simply parsing every character one by one, without using indexOf. I hope I get what you're doing correctly: const str = 'String <smile> string <clap>.' Basically in case character is not < or > you simply get the node with corresponding character. In case it faces "<" it switches switches isEmoji to true, and starts accumulating characters in to emojiStr. As it faces ">" it switches isEmoji back, and you also get the emoji node. It switches isEmoji back to false, and keeps capturing individual symbols. Edit: just read your last message. Good it is fixed. |
||||
|
You guys are legends for doing this kind of work. Just wanted to say that. I certainly envy you. :) |
||||
|
Hello! I am very new to coppercube and my very basic knowledge is in Lazarus Pascal (I know exactly where I can use codes in my application). Please, when using javascript in my games where can I use it so that it works. Please, a complete list of where I can be applying javascript and how it can be used? |
||||
|
Hi josevaldo, Im happy in see new devs in coppercube engine, welcome! You can use javascript for a great list of actions ans behaviors, look this list, explain better how to use javascript in Coppercube! https://www.ambiera.com/coppercu... CopperCube JavaScript reference CopperCube provides a very simple interface to manipulate all aspects of a 3D scene. See CopperCube Scripting overview for a short description on how to do this. This file lists all available functions. Most of these functions manipulate so called 'scene nodes'. A scene node is nothing more than a 3d object with a position, rotation, scale, its materials and children. The name 'scene node' is there because CopperCube is internally using a scene graph to represent the 3d scene. Scene Node Handling ccbCloneSceneNode ccbGetActiveCamera ccbSetActiveCamera ccbGetChildSceneNode ccbGetRootSceneNode ccbGetSceneNodeChildCount ccbGetSceneNodeProperty ccbSetSceneNodeProperty ccbGetSceneNodeFromName ccbGetSceneNodeMaterialCount ccbGetSceneNodeMaterialProperty ccbSetSceneNodeMaterialProperty ccbRemoveSceneNode ccbSetSceneNodeParent ccbSetSceneNodePositionWithoutCollision Events ccbRegisterKeyDownEvent ccbRegisterKeyUpEvent ccbRegisterMouseDownEvent ccbRegisterMouseUpEvent ccbRegisterOnFrameEvent ccbUnregisterOnFrameEvent Drawing ccbDrawColoredRectangle ccbDrawTextureRectangle ccbDrawTextureRectangleWithAlpha Collision ccbGet3DPosFrom2DPos ccbGet2DPosFrom3DPos ccbGetCollisionPointOfWorldWithLine ccbDoesLineCollideWithBoundingBoxOfSceneNode Various ccbEndProgram ccbLoadTexture ccbGetMousePosX ccbGetMousePosY ccbSetMousePos ccbGetScreenWidth ccbGetScreenHeight ccbSetCloseOnEscapePressed ccbSetCursorVisible ccbSwitchToScene ccbPlaySound ccbStopSound ccbGetCopperCubeVariable ccbSetCopperCubeVariable ccbReadFileContent ccbWriteFileContent ccbFileExist ccbFileDelete ccbGetPlatform ccbInvokeAction ccbGetCurrentNode ccbCleanMemory ccbSwitchToFullscreen ccbDoHTTPRequest ccbCancelHTTPRequest ccbCreateMaterial ccbSetShaderConstant ccbSetPhysicsVelocity ccbUpdatePhysicsGeometry ccbAICommand ccbSteamSetAchievement ccbSteamResetAchievements ccbSaveScreenshot ccbSaveTexture ccbSwitchToCCBFile system Only in the editor confirm alert prompt editorAddSceneNode editorFocusPosition editorGetFileNameFromDialog editorGetSelectedSceneNode editorGetSelectedTexture editorUpdateAllWindows editorRegisterMenuEntry editorSetSelectedSceneNode editorImportStatic3DMesh editorImportAnimated3DMesh Mesh Editing ccbGetSceneNodeMeshBufferCount ccbRemoveMeshBuffer ccbAddMeshBuffer ccbGetMeshBufferVertexCount ccbGetMeshBufferIndexCount ccbAddMeshBufferIndex ccbGetMeshBufferIndexValue ccbSetMeshBufferIndexValue ccbAddMeshBufferVertex ccbGetMeshBufferVertexPosition ccbSetMeshBufferVertexPosition ccbGetMeshBufferVertexTextureCoord ccbSetMeshBufferVertexTextureCoord ccbGetMeshBufferVertexNormal ccbSetMeshBufferVertexNormal ccbGetMeshBufferVertexColor ccbSetMeshBufferVertexColor ccbUpdateSceneNodeBoundingBox |
|