User Tag List

Results 1 to 4 of 4

Thread: Need help in loading sprites dynamically during runtime for each player

  1. #1
    Clicker Fusion 2.5 DeveloperInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Sep 2016
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help in loading sprites dynamically during runtime for each player

    I'm not sure if it's okay to bump topics, but I'd really love to get an answer on this question made by someone 4 years ago:
    https://community.clickteam.com/threads/89481-Best-object-for-displaying-sprites-generated-at-runtime

    My idea is a Smash Bros-like platformer battle game where every player loads their own character that they draw. The characters would be a series of image files in a folder. Loading sprites dynamically via the Load Frame command has an issue. All instances of an Active object share the same frame memory and because of this, it's impossible to load individual player sprites. Now, I don't want to and I shall not use 4 clones of Player object because I don't know how many players there would actually be. Also, that would be a dirty way of programming things. What if I have a chatroom app where the number of sprites is unpredictable?

    What I was thinking about doing is to load all frames into an Active object called AllSprites which serves as a buffer for sprites. The sprites are loaded into the Stopped animation in all 32 directions and using a lot of frames. If the max number of frames is exceeded, it goes to the next animation sequence. Bind every physical character instance with every newly created AllSprites instance by using Fixed values and then have each AllSprites instance snap onto its appropriate character instance and change its animation sequence and frame according to which sprite needs to be shown. I'd have to have a structured array like character>animation>frame pointing to which frame in which sequence the desired sprite is in the AllSprites object and I'd have to have it all be managed with a special animation manager object that takes care of every sprite being allocated and deallocated as the game wants so that I don't get huge memory leaks and other issues.

    Is this even possible to do and is this even a good idea to achieve my goal? How easy/hard is it to make my own extension in C++ and for all platforms?

  2. #2
    Clickteam Clickteam
    Simon's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    2,680
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    This one is going to be a bit involved in Fusion. So there are a couple of issues in your way here... when loading images into actives at runtime, you can't change the number of frames or the looping of the animation into which you're loading the images. Because of this you cannot create a new animation, only overwrite the images of an existing one.

    My suggestion is (assuming you enforce the same number of frames of animation for each player to create their animation within), you create an active object which has the following:

    "Stopped" animation with all of the frames for all of the directions configured (just fill each with solid black or something) and looping set.
    If you want to allow up to 50 custom players' graphics, create 50 animations in the object after the "Stopped" one, and paste the dummy animation from "Stopped" into each one.
    The default animations are listed (Walking, Running, Appearing and so on... up to Stand Up). There are 11 of these and they can't be renamed. I suggest for your reference you name each following one 12, 13, 14 and so on.
    When you come to load frames into an animation at runtime, you can choose the animation by clicking "Use a calculation" instead of selecting one from the list. In this way you can choose any number of animation up to 50 in this example and load frames in as per your needs.

    Because Fusion compares all of the graphics in your MFA when you add them at edit time, the 50 copies of the animations with the black squares in them will all be stored as a single black image (so long as they are all identical) so you won't be wasting a load of memory/storage space here.

    Obviously this limits you to 50 players, but you can add additional animations (I don't know what the upper limit to the number of animations is but I got beyond 50 and it was still allowing me to add new ones). There is always going to be a hard limit this way based on the number of dummy animations you've added and you will always have to use the same number of frames etc. but this approach should in theory work cross platform.

    What you're trying to do is a tricky bit of programming in Fusion though as it doesn't really have the tools to handle this at the moment. Spriter has an extension which you can load animations into Fusion with although not cross platform, you can check it out here: http://clickstore.clickteam.com/spriter_extension

  3. #3
    Clicker Fusion 2.5 DeveloperInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Sep 2016
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you.

    Now, I was thinking about something. What if a player decides to be silly and loads a huuuuuuge resolution'd picture and if the game was online multiplayer? How could I possibly check for an image its resolution before importing it and before having a player's client send the picture to the server?

    Also, does Spriter extension load sprites that aren't made in Spriter program? I haven't bought Spriter and I would like the loading of sprites to be such that a player can make their sprites in the simplest program like MS Paint.

  4. #4
    Clickteam Clickteam
    Simon's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    2,680
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    I genuinely don't know the Spriter extension at all, except that I looked whilst writing that reply and it can load in external images. You'll have to have a play around yourself.

    As for large images - you would basically need to resize them yourself. Active Picture Object can do this for one thing. You could also manipulate images on a server using php.

Similar Threads

  1. Player Drawn Sprites at Runtime
    By Soilydude in forum Fusion 2.5
    Replies: 2
    Last Post: 18th January 2017, 03:47 PM
  2. Loading too many sprites
    By psychoanima in forum Android Export Module 2.5
    Replies: 9
    Last Post: 20th November 2016, 08:43 PM
  3. Loading sprites at runtime
    By astrospoon in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 4th September 2008, 03:32 AM
  4. Create sprites using spritesheets during runtime
    By Pablo in forum File Archive
    Replies: 0
    Last Post: 18th October 2007, 10:44 PM
  5. Loading sprites during runtime?
    By Blizna in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 1st July 2006, 07:47 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
  •