Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private function getSprite(regionAttachment:RegionAttachment):FlxSprite
- {
- //if (Registry.PLAYER_1_CUSTOM_HEAD != 0)
- //{
- //trace("we picked head before, trying to set");
- //Registry.PLAYER_1_CUSTOM_HEAD = 0;
- //refresh = true;
- //}
- if(refresh==false)
- if (regionAttachment.wrapperSprite != null && Std.is(regionAttachment.wrapperSprite, FlxSprite))
- return cast(regionAttachment.wrapperSprite, FlxSprite);
- // trace("get sprite");
- var region:AtlasRegion = cast regionAttachment.rendererObject;
- var graph:FlxGraphic = cast(region.page.rendererObject, FlxGraphic);
- var regionWidth:Float = region.rotate ? region.height : region.width;
- var regionHeight:Float = region.rotate ? region.width : region.height;
- var atlasFrames:FlxAtlasFrames = (graph.atlasFrames == null) ? new FlxAtlasFrames(graph) : graph.atlasFrames;
- var name:String = region.name;
- var offset:FlxPoint = FlxPoint.get(0, 0);
- var frameRect:FlxRect = new FlxRect(region.x, region.y, regionWidth, regionHeight);
- var sourceSize:FlxPoint = FlxPoint.get(frameRect.width, frameRect.height);
- var imageFrame = FlxImageFrame.fromFrame(atlasFrames.addAtlasFrame(frameRect, sourceSize, offset, name));
- if (regionAttachment.name.indexOf("alien/masks/custom") >=0)
- {
- var amountOfLevelsOnDisk:Int = 0;
- var directory:String;
- // if(Registry.USE_LOCAL_FOLDERS)
- directory = "assets/custom heads/pack";
- // else
- // directory = "../../../../assets/custom heads/pack";
- files = new Array<String>();
- if (FileSystem.exists(directory))
- {
- trace("directory found: " + directory);
- for (file in FileSystem.readDirectory(directory))
- {
- var path = Path.join([directory, file]);
- if (!FileSystem.isDirectory(path))
- {
- files.push(path);
- // trace("file found: " + path);
- // trace("files found");
- // do something with file
- }
- else
- {
- //var directory = Path.addTrailingSlash(path);
- //trace("directory found: " + directory);
- //recursiveLoop(directory);
- }
- }
- }
- else
- {
- trace('"$directory" does not exists');
- }
- trace("mask detected, replacing");
- var wrapper2:FlxSprite = new FlxSprite("assets/custom heads/custom1.png");
- if (regionAttachment.name.indexOf("alien/masks/custom1") >=0)
- wrapper2.loadGraphic("assets/custom heads/custom1.png");
- if (regionAttachment.name.indexOf("alien/masks/custom2") >=0)
- wrapper2.loadGraphic("assets/custom heads/custom2.png");
- if (regionAttachment.name.indexOf("alien/masks/custom3") >=0)
- wrapper2.loadGraphic("assets/custom heads/custom3.png");
- if (regionAttachment.name.indexOf("alien/masks/custom4") >=0)
- wrapper2.loadGraphic("assets/custom heads/custom4.png");
- if (refresh)
- {
- if (regionAttachment.name.indexOf("alien/masks/custom1") >= 0)
- {
- trace("picked head " + files[Registry.PLAYER_1_CUSTOM_HEAD].toString());
- wrapper2.loadGraphic(files[Registry.PLAYER_1_CUSTOM_HEAD].toString());
- // wrapper2.loadGraphic("assets/custom heads/pack/commandervideo.png");
- }
- }
- refresh = false;
- imageFrame = FlxImageFrame.fromGraphic(wrapper2.graphic);
- }
- var wrapper:FlxSprite = new FlxSprite();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement