Thread: Custom Sprite Cache

Page 12 of 13 FirstFirst ... 210111213 LastLast
Results 111 to 120 of 121
  1. #111  
    Registered Member cPanelDB's Avatar
    Join Date
    Feb 2014
    Posts
    51
    Thanks given
    12
    Thanks received
    7
    Rep Power
    24
    Found out the error i'm getting when i repack the sprites why does the ID change ?
    Need help to get this fixed
    Reply With Quote  
     

  2. #112  
    Server Developer

    Join Date
    Oct 2015
    Age
    24
    Posts
    97
    Thanks given
    17
    Thanks received
    13
    Rep Power
    13
    Sorry for gravedig, can someone give me the link of the updated version?

    Thanks
    Reply With Quote  
     

  3. #113  
    Registered Member
    Join Date
    Oct 2012
    Posts
    7
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    1234
    Reply With Quote  
     

  4. #114  
    Registered Member
    Join Date
    Sep 2009
    Posts
    42
    Thanks given
    0
    Thanks received
    2
    Rep Power
    1
    Quote Originally Posted by nucleon View Post
    I noticed that if you pack 10+ sprites named 0.png (e.g. [0,1,2,3,4,5,6,7,8,9,10,11]) it will list them improperly ([0,1,10,11,2,3,4,5,6,7,8,9]).

    Sorting will fix this glitch:

    Code:
    import java.util.Comparator;
    Code:
    public static void buildSpriteList() {
            Main.log("Building list of image files in the sprites folder...");
            int id = 0;
            Arrays.sort(files, new Comparator<File>() {
                @Override
                public int compare(File o1, File o2) {
                    int n1 = extractNumber(o1.getName());
                    int n2 = extractNumber(o2.getName());
                    return n1 - n2;
                }
    
    
                private int extractNumber(String name) {
                    int i = 0;
                    try {
                        int s = name.indexOf(" ") + 1;
                        int e = name.lastIndexOf(".png");
                        String number = name.substring(s, e);
                        i = Integer.parseInt(number);
                    } catch (Exception e) {
                        i = 0; // if filename does not match the format
                        // then default to 0
                    }
                    return i;
                }
            });
            for (File f : files) {
                if (f.isDirectory()) {
                    continue;
                }
                if (!f.getName().contains(".png")) {
                    continue;
                }
                spriteFiles.add(new FileSprite(id, fileToByteArray(f)));
                System.out.println(f.getName() + ", " + id);
                id++;
            }
            Main.log("Found " + spriteFiles.size() + " images in the sprites folder!");
        }
    Thanks that fixed the numbering being wrong issue. Just change what he has here but make sure to also import the java.util.Arrays; and leave File[] files = new File(Constants.getSpritesLocation()).listFiles(); in the buildSpriteList method. Just in case anyone else is having this issue since I couldn't find an up to date jar in the thread that didn't have this issue.
    Reply With Quote  
     

  5. #115  
    Registered Member
    Join Date
    Mar 2015
    Posts
    8
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    Quote Originally Posted by Galkon View Post

    Reupload please?

    Trying to use this but I'm having the same issue where the numbering is all messed up.


    Nvm fixed it. Thanks tannermon11 ^
    Reply With Quote  
     

  6. #116  
    Registered Member
    Join Date
    Mar 2014
    Posts
    1
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Still getting errors with spritefiles and filetobytearray
    Reply With Quote  
     

  7. #117  
    Donator


    Join Date
    Jan 2010
    Age
    29
    Posts
    4,122
    Thanks given
    274
    Thanks received
    551
    Rep Power
    738
    Edit: didnt see someone posted the fix
    Reply With Quote  
     

  8. #118  
    Registered Member
    Join Date
    Mar 2019
    Posts
    9
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Actually triggered because no one has bothered to say how to open this god damn program, stupid people
    Reply With Quote  
     

  9. #119  
    Extreme Donator

    woof woof bish's Avatar
    Join Date
    May 2011
    Age
    26
    Posts
    2,444
    Thanks given
    2,212
    Thanks received
    1,019
    Rep Power
    5000
    Quote Originally Posted by Okamisama View Post
    Actually triggered because no one has bothered to say how to open this god damn program, stupid people
    yeah you might as well quit your project if you don't know how to do it stoopid
    Reply With Quote  
     

  10. #120  
    Registered Member
    Join Date
    Mar 2019
    Posts
    9
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Quote Originally Posted by woof woof bish View Post
    yeah you might as well quit your project if you don't know how to do it stoopid
    Rough I said that out of anger, for some reason All my files were set to open with Winrar. rip
    Reply With Quote  
     

Page 12 of 13 FirstFirst ... 210111213 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [508] Custom login music [custom cache]
    By lukas265 in forum Show-off
    Replies: 7
    Last Post: 07-23-2010, 06:22 PM
  2. Custom sprite cache
    By 35518 in forum Snippets
    Replies: 12
    Last Post: 12-16-2009, 03:14 PM
  3. Custom sprite help!
    By Tweezy in forum Help
    Replies: 4
    Last Post: 07-06-2009, 12:27 PM
  4. custom sprite
    By jer123 in forum Help
    Replies: 4
    Last Post: 06-07-2009, 01:36 AM
  5. Custom sprite loading
    By Auruo in forum Help
    Replies: 1
    Last Post: 02-16-2009, 02:13 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
  •