How do I create a hashtag system?

0 favourites
  • 10 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I'm attempting to create text that has multiple imbedded links.

    Something similar to (or even exactly like) how a social media site has hashtags, user links (#/@), and/or hyperlinks.

    I'd like to be able to direct each link (determine via my code whether the link opens a new browser tab or opens inside an iframe,etc).

    {Example: Player1 creates a message and sends it to the server. The message contains the name player2 and Player2 and 3 check the server and get their message from player1. Player2 wants to view the game stats for player3, so he clicks on his name inside the message.

    From player1: "Hi @player2 and #player3 are you all interested in someURL.xyz?"}

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • About the simplest method would be to make your own custom sprite font out of Sprites.

    One letter per frame and have the special characters have their bounding boxes be bigger than the other letters. You would then compare the frame, or instance variable when the frame is clicked.

    I assume you already figured out the parsing.

    Making a custom size bounding box would be another matter as you cant change the width without changing the texture, unless you use a mesh, or a hierarchy.

  • Been messing with using tokenat and an array for words. Then recombining everything into a pattern that mimics a text area (using your idea). Seems to be pretty good. Using regex to format for and # in the mix (https too).

    Do you happen to know the memory usage of doing this if there are 50k individual text boxes, but 99% are off screen?

  • Don't use text, or text box. They are hard on the system.

    You could maybe get away with Spritefont.

  • I'm just testing all this and appreciate your input. (I'm using you as a sounding board)

    I have a message that, parse into an array, then use the array to create text (we used to call them textareas) and line them up so they wrap, etc and look like a normal textarea should.

    C3 doesn't like creating items outside of about Y=42000.

    1800 textareas works fine.

    Pin is awful 9% cpu usage sitting idle, 19% when scrolling.

    Hierarchy is great 1.6% idle, 7% scrolling.

    The new functions are amazing, 1800 are instantly created. (0.6mb of images, 60fps)

    In the function I just compare the left(text.text,1) and look for #,@, or https,etc (will need multiples for hyperlinks) and bbcode them. Then set a variable to tell me what's what so it's easy to direct the link based on that variable.

    I'm gonna test it either way, but you think I can pick up much performance using a spritefont? I've been using this for 6 years, and have yet to really figure out how to save cpu usage other than by good coding.

    Ran a test using spritefont vs textarea. Identical, 1.6% bouncing to 7% max for either.

  • Text and Textbox will cause issues if you are constantly changing them.

    Spritefont shouldn't because the texture is already loaded.

  • Last dumb one...I'll only be creating the chat text 1 time per cycle (on open chat bar). Each will be static (no changes at all except x,y).

    Performance wise, you think that'll be a big enough deal to warrant going through the effort to have the spritefont.textwidth/height format properly? (I'm setting box size based on the textwidth/height criteria.)

  • It should be easy to figure out per word. Len() x character width.

  • Have this all working, but not sure how to handle one little aspect.

    Create the spritefont with text: "ghasgkasghdagdsakjhgskahjgdfshgashgdfsahgdfsa" and setting it for word wrap, the text trails off the screen.

    Setting it for character wrap, leaves a dead space on the second line.

    You know of any way to compensate for that?

    There isn't a way to find the x,y of a particular character within a string that I am aware. (If there were, it would be easy to wrap character and then spawn a new spritefont based on that x,y) I guess all I can do is use the word wrap and depend on the user to put things in the proper format?

  • You would have to keep track of the length of the lines externally.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)