Skip to content

Commit

Permalink
multi atlas stuff
Browse files Browse the repository at this point in the history
probably shoulda put this in the update today OH WELL
also stolen from psych
  • Loading branch information
ThatRozebudDude committed Feb 5, 2025
1 parent 9b851c8 commit 35a5d88
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions source/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ class Character extends FlxSpriteGroup
case sparrow:
character = new FlxSprite();
character.frames = Paths.getSparrowAtlas(characterInfo.info.spritePath);
case multiSparrow:
character = new FlxSprite();
character.frames = Paths.getMultipleSparrowAtlas(characterInfo.info.spritePaths);
case packer:
character = new FlxSprite();
character.frames = Paths.getPackerAtlas(characterInfo.info.spritePath);
Expand Down
17 changes: 17 additions & 0 deletions source/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,23 @@ class Paths
return 'assets/images/$key';
}

//Stolen from Psych Engine hehehhehe
inline static public function getMultipleSparrowAtlas(keys:Array<String>){
var parentFrames:FlxAtlasFrames = getSparrowAtlas(keys[0]);
if(keys.length > 1){
var original:FlxAtlasFrames = parentFrames;
parentFrames = new FlxAtlasFrames(parentFrames.parent);
parentFrames.addAtlas(original, true);
for (i in 1...keys.length){
var extraFrames:FlxAtlasFrames = getSparrowAtlas(keys[i]);
if(extraFrames != null){
parentFrames.addAtlas(extraFrames, true);
}
}
}
return parentFrames;
}

inline static public function video(key:String){
return file(key, "videos", "mp4");
}
Expand Down
4 changes: 4 additions & 0 deletions source/characters/CharacterInfoBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ enum FrameLoadType {
packer;
load(frameWidth:Int, frameHeight:Int);
atlas;
multiSparrow;
}

typedef AnimInfo = {
Expand Down Expand Up @@ -71,6 +72,7 @@ typedef CharacterFunctions = {
typedef CharacterInfo = {
var name:String;
var spritePath:String;
var spritePaths:Array<String>;
var frameLoadType:FrameLoadType;
var iconName:String;
var deathCharacter:String;
Expand Down Expand Up @@ -109,6 +111,7 @@ class CharacterInfoBase
public var info:CharacterInfo = {
name: "",
spritePath: "",
spritePaths: [],
frameLoadType: sparrow,
iconName: "face",
deathCharacter: "Bf",
Expand Down Expand Up @@ -430,6 +433,7 @@ class CharacterInfoBase
function setPacker():FrameLoadType{ return FrameLoadType.packer; }
function setLoad(frameWidth:Int, frameHeight:Int):FrameLoadType{ return FrameLoadType.load(frameWidth, frameHeight); }
function setAtlas():FrameLoadType{ return FrameLoadType.atlas; }
function setMultiSparrow():FrameLoadType{ return FrameLoadType.multiSparrow; }

public function toString():String{ return ""+info; }
}

0 comments on commit 35a5d88

Please sign in to comment.