How do I make click on a word in a spritefont triggers an action ?

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
Click! Click! 136 click sounds for your video games or media projects
  • Hello,

    I saw that "BBCODE tag ranges" example makes it possible to make a word in spritefont react to touch.

    But I'd like to set up a function that click on a word triggers an action.

    I though of something like a tag that would tell every word with this tag acts as a button (ie [tag=button] but another tag would be useful to indicate an ID to that button. Or maybe some regex could be involved to decrypt a tag in the form [tag=button/3].

    Then, using a json to connect ID with an action, I'd be able to trigger a given action with a click on given word.

    Any idea how this could be achieved ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use the TagAtPosition expression and then run the corresponding function for each tag. Or you can look up that tag in an array/dictionary/JSON to retrieve any additional information associated with it.

    + Mouse: On Left button Clicked on SpriteFont
     | Local string tag‎ = 
    ----+ (no conditions)
    -----> System: Set tag to SpriteFont.TagAtPosition(Mouse.X, Mouse.Y)
    
    ----+ System: tag = "foo"
    -----> Functions: Call Foo
    
    ----+ System: tag = "bar"
    -----> Functions: Call Bar
    
    
  • Thank you !

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