User Tag List

Results 1 to 10 of 10

Thread: There's a way to limit characters of String Object?

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module
    paobrasil's Avatar
    Join Date
    Apr 2012
    Location
    Rio de Janeiro, Brazil
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy There's a way to limit characters of String Object?

    Hello again my friends. I want to limit a maximum of characters on a string object.

    My mobile game have a keyboard that I've created, but when I write a lot of chars, the string object create another line below and "crash" my game design. So, I just need to know a expression or a condition that limit maximum of characters of my string object...for example 15 characters.

    There's a way to do this?

    Best regards!

  2. #2
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jun 2006
    Location
    England
    Posts
    3,512
    Mentioned
    3 Post(s)
    Tagged
    1 Thread(s)
    There are two string functions described under the Expressions section of the Special Object in the Fusion 2.5 help documentation that can do what you want:
    Length of string returns the number of characters in the given string. Example, LEN("Hello") returns 5.
    Extract left sub-string extracts a sub-string from the given string, starting on the left. Example, LEFT$("Hello", 3) will return "Hel".
    So you can use Len to check if the input is too long and Left$ to shorten the string down to within the limit. Both of these are functions of the Special Object (Special Object -> Strings), but are also listed in the main section of the Expression Editor (just below where it says "Valid Expression", "Syntax Error", etc).
    .:::.Joshtek.:::.

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module
    paobrasil's Avatar
    Join Date
    Apr 2012
    Location
    Rio de Janeiro, Brazil
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much my friend! I'll try it.

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module
    paobrasil's Avatar
    Join Date
    Apr 2012
    Location
    Rio de Janeiro, Brazil
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've got it! THANK YOU!

    Just one more question......I'm trying to remove the last character on MYSTRING while users click on a BUTTON (like a backspace).....so I did:

    • Repeat while left mouse is pressed
    • Mouse pointer is over BUTTON
    then:
    - Left$(string$( "MYSTRING" ), Len(string$( "MYSTRING" ) ) - 1 )


    Well...it's working...but I've got a problem....every click, the action remove more then one character....it's impossible to remove only the last character....If I change the condition to user clicks left on BUTTON....then I can remove one character only...but the user needs to click everytime he wants to clear the character, he can't just press and wait to remove all characters..

    You know why ?

  5. #5
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    It's due to the amount of events being looped per second. When you hold the mouse down it's executing your event actions for however many event loops per second you have... The default is 50... so if you hold down the LMB it's going to remove 50 characters per second. :P

    I'm assuming you want it to just have a delay... well then you can add a delay by creating a variable that counts down over time. This is the standard way of making timers/delays for Fusion games:

    1. Create a variable somewhere... either in an active object or a global value. (this step doesn't actually involve doing anything, other than determining where you want to store your delay value)

    2. In your mouse press event, add a condition of "if variable = 0" (using the variable you chose)

    3. Then in the mouse press event action, create an action to set that variable to... 25.

    4. Then create a new event with the condition "if variable > 0" and the action should be "subtract 1 from variable"


    Done! Now when you hold down the mouse button, it performs your "backspace" action one time, and then sets that variable to 25... and then it runs 25 game loops before it is set back to zero and can execute the backspace action again.

    So you just create your own delay. Of course you can adjust the 25 to whatever you want. I'm assuming your game's frame rate is 50 fps, so that means 25 would be every half second.

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module
    paobrasil's Avatar
    Join Date
    Apr 2012
    Location
    Rio de Janeiro, Brazil
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you konidias....

    It's a little confused to me (not because you explanation, but my knowledge)....I will try to read more 10 times to uderstand

    I'm using 60fps..

  7. #7
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleXNA Export Module
    ProdigyX's Avatar
    Join Date
    Jan 2011
    Posts
    1,194
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    +User Presses button 'xyz'
    +Only one action per event loop
    -Action

  8. #8
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    That will only execute the action one time per button press though... he's wanting it to continue the action while the left mouse button is held... but not so rapidly as once every loop.

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module
    paobrasil's Avatar
    Join Date
    Apr 2012
    Location
    Rio de Janeiro, Brazil
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ABSOLUTELY FANTASTIC!

    It works! Thank you not only for the help, but to the lesson about how to handle timer/delays too.

    Best regards!

  10. #10
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    No problem! Glad it worked out for you.

Similar Threads

  1. [bug rc7] Special Characters GET OBJECT/STRING
    By StingRay in forum Android Export Module Version 2.0
    Replies: 0
    Last Post: 27th March 2013, 12:32 PM
  2. String Parser 2 limit number of characters
    By ASD in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 8th June 2012, 09:01 PM
  3. String Object doesn't show special characters correctly
    By JoKa in forum iOS Export Module Version 2.0
    Replies: 2
    Last Post: 15th November 2011, 08:31 AM
  4. replace characters in a string?
    By Gibbon in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 10th October 2011, 01:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •