I don't even know what I changed at this point
This commit is contained in:
parent
444457db2a
commit
daa2093e26
@ -15,7 +15,8 @@
|
|||||||
|
|
||||||
<!-- classpath, haxe libs -->
|
<!-- classpath, haxe libs -->
|
||||||
<source path="src" />
|
<source path="src" />
|
||||||
<assets path="res/sprites" rename="sprites" />
|
<assets path="res/textures" rename="textures" />
|
||||||
|
<assets path="res/data" rename="data"/>
|
||||||
<haxelib name="openfl" />
|
<haxelib name="openfl" />
|
||||||
<haxelib name="actuate" />
|
<haxelib name="actuate" />
|
||||||
|
|
||||||
|
|||||||
18
hGameTest/res/data/textures.json
Normal file
18
hGameTest/res/data/textures.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"dataScheme":"textureList",
|
||||||
|
"version":1,
|
||||||
|
"textureData": {
|
||||||
|
"spriteSheets":[{
|
||||||
|
"sheetName":"testSheet",
|
||||||
|
"path":"sheets/sheet.png",
|
||||||
|
"sheetDataPath":"sheets/sheet.json",
|
||||||
|
"explicitDimensions":true,
|
||||||
|
"tileDimensions":{"width":16,"height":16}
|
||||||
|
}],
|
||||||
|
"sprites":
|
||||||
|
[{
|
||||||
|
"spriteName":"player",
|
||||||
|
"path":"individual/character.png"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
36
hGameTest/res/textures/sheets/sheet.htex.json
Normal file
36
hGameTest/res/textures/sheets/sheet.htex.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"datascheme":"htex",
|
||||||
|
"version":1,
|
||||||
|
"textureData":{
|
||||||
|
"texName":"testsheet",
|
||||||
|
"texType":"atlas",
|
||||||
|
"atlas":{
|
||||||
|
"atlasType":"tilesetgeneric",
|
||||||
|
"tileSize":{
|
||||||
|
"x":16,
|
||||||
|
"y":16
|
||||||
|
},
|
||||||
|
"tilesetGeneric":{
|
||||||
|
"baseTexture":"textures/sheets/sheet.png",
|
||||||
|
"tiles":[
|
||||||
|
"testTile1",
|
||||||
|
"testTile2",
|
||||||
|
"testTile3",
|
||||||
|
"testTile4",
|
||||||
|
"testTile5",
|
||||||
|
"testTile6",
|
||||||
|
"testTile7",
|
||||||
|
"testTile8",
|
||||||
|
"testTile9",
|
||||||
|
"testTile10",
|
||||||
|
"testTile11",
|
||||||
|
"testTile12",
|
||||||
|
"testTile13",
|
||||||
|
"testTile14",
|
||||||
|
"testTile15",
|
||||||
|
"testTile16"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
hGameTest/res/textures/sheets/sheet.png
Normal file
BIN
hGameTest/res/textures/sheets/sheet.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 607 B |
36
hGameTest/res/textures/sheets/sheetAnim.htex.json
Normal file
36
hGameTest/res/textures/sheets/sheetAnim.htex.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"datascheme":"htex",
|
||||||
|
"version":"1",
|
||||||
|
"textureData":{
|
||||||
|
"texName":"testsheet",
|
||||||
|
"texType":"atlas",
|
||||||
|
"atlas":{
|
||||||
|
"atlasType":"tilesetgeneric",
|
||||||
|
"tileSize":{
|
||||||
|
"x":16,
|
||||||
|
"y":16
|
||||||
|
},
|
||||||
|
"tilesetGeneric":{
|
||||||
|
"baseTexture":"textures/sheets/sheet.png",
|
||||||
|
"tiles":[
|
||||||
|
"testTile1",
|
||||||
|
"testTile2",
|
||||||
|
"testTile3",
|
||||||
|
"testTile4",
|
||||||
|
"testTile5",
|
||||||
|
"testTile6",
|
||||||
|
"testTile7",
|
||||||
|
"testTile8",
|
||||||
|
"testTile9",
|
||||||
|
"testTile10",
|
||||||
|
"testTile11",
|
||||||
|
"testTile12",
|
||||||
|
"testTile13",
|
||||||
|
"testTile14",
|
||||||
|
"testTile15",
|
||||||
|
"testTile16"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 161 B After Width: | Height: | Size: 161 B |
@ -5,6 +5,9 @@ import openfl.display.BitmapData;
|
|||||||
import openfl.display.Sprite;
|
import openfl.display.Sprite;
|
||||||
import openfl.events.Event;
|
import openfl.events.Event;
|
||||||
import openfl.Assets;
|
import openfl.Assets;
|
||||||
|
import assets.TextureData;
|
||||||
|
import assets.SpriteSheet;
|
||||||
|
import assets.Scanner;
|
||||||
|
|
||||||
class Game
|
class Game
|
||||||
{
|
{
|
||||||
@ -19,10 +22,15 @@ class Game
|
|||||||
stage.addChild(player);
|
stage.addChild(player);
|
||||||
//player.graphics.lineStyle(2,0xFF0000);
|
//player.graphics.lineStyle(2,0xFF0000);
|
||||||
//player.graphics.drawRect(0,0,16,16);
|
//player.graphics.drawRect(0,0,16,16);
|
||||||
var bitmapData:BitmapData = Assets.getBitmapData("sprites/character.png");
|
// var bitmapData:BitmapData = Assets.getBitmapData("textures/sprites/character.png");
|
||||||
var playerBitmap:Bitmap = new Bitmap(bitmapData);
|
var sheetData:BitmapData = Assets.getBitmapData("textures/sheets/sheet.png");
|
||||||
|
var sheet:SpriteSheet = new SpriteSheet(sheetData);
|
||||||
|
|
||||||
|
var playerBitmap:Bitmap = new Bitmap(sheet.sprites[15]);
|
||||||
playerBitmap.scaleX = playerBitmap.scaleY = 10;
|
playerBitmap.scaleX = playerBitmap.scaleY = 10;
|
||||||
player.addChild(playerBitmap);
|
player.addChild(playerBitmap);
|
||||||
|
//TextureData.parseConfig();
|
||||||
|
Scanner.scanTextureDir();
|
||||||
//Sys.
|
//Sys.
|
||||||
}
|
}
|
||||||
public function onEnterFrame(e:Event):Void
|
public function onEnterFrame(e:Event):Void
|
||||||
|
|||||||
@ -1,16 +0,0 @@
|
|||||||
import openfl.display.BitmapData;
|
|
||||||
import openfl.display.Bitmap;
|
|
||||||
class SpriteSheet{
|
|
||||||
public static var spriteSheetArray:Array<SpriteSheet> = [];
|
|
||||||
public var sprites:Array<Bitmap> = [];
|
|
||||||
public function new(bmp:Bitmap = null, sprWidth:Int = 16, sprHeight:Int = 16){
|
|
||||||
spriteSheetArray.push(this);
|
|
||||||
var columns:Int = cast((bmp.width / sprWidth),Int);
|
|
||||||
var rows:Int = cast((bmp.height / sprHeight),Int);
|
|
||||||
for(i in 0...columns){
|
|
||||||
for (j in 0...rows){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
28
hGameTest/src/assets/HTex.hx
Normal file
28
hGameTest/src/assets/HTex.hx
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package assets;
|
||||||
|
|
||||||
|
import openfl.display.BitmapData;
|
||||||
|
import assets.schema.HTexSchema.TexV1;
|
||||||
|
|
||||||
|
class HTex{
|
||||||
|
public static var hTexArray:Array<HTex> = [];
|
||||||
|
public var bitmaps:Array<BitmapData>;
|
||||||
|
public var name:String = "";
|
||||||
|
public function new(_name:String){
|
||||||
|
name = _name;
|
||||||
|
if(hTexArray[name] == null)
|
||||||
|
hTexArray[name] = name;
|
||||||
|
}
|
||||||
|
public static function createTextureObjectFromJSON(path:String){
|
||||||
|
var DATA:TexV1;
|
||||||
|
var loadedData:String = Assets.getText(path);
|
||||||
|
var jsondata = Json.parse(loadedData);
|
||||||
|
DATA = jsondata;
|
||||||
|
DATA = TexV1;
|
||||||
|
if(DATA.dataScheme == "htex"){
|
||||||
|
if(DATA.version == 1){
|
||||||
|
var texdata:TextureDataV1 = Data.textureData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
33
hGameTest/src/assets/Scanner.hx
Normal file
33
hGameTest/src/assets/Scanner.hx
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package assets;
|
||||||
|
import sys.io.File;
|
||||||
|
import sys.FileSystem;
|
||||||
|
|
||||||
|
class Scanner{
|
||||||
|
public static function scanTextureDir(){
|
||||||
|
scanDirsRecursively("textures");
|
||||||
|
}
|
||||||
|
public static var textures:Array<String> = [];
|
||||||
|
public static var dirsToScan:Int = 1;
|
||||||
|
public static function scanDirsRecursively(cd:String){
|
||||||
|
var textureDir:Array<String> = FileSystem.readDirectory(cd);
|
||||||
|
cd+="/";
|
||||||
|
trace(textureDir);
|
||||||
|
for(dir in textureDir){
|
||||||
|
if(FileSystem.isDirectory(cd+dir)){
|
||||||
|
dirsToScan++;
|
||||||
|
trace("Scanning dir: "+dir);
|
||||||
|
scanDirsRecursively(cd+dir);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(dir.indexOf(".htex.json") > -1){
|
||||||
|
textures.push(cd+dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dirsToScan--;
|
||||||
|
if(dirsToScan == 0){
|
||||||
|
trace("Finished scanning");
|
||||||
|
trace(textures);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
hGameTest/src/assets/SpriteSheet.hx
Normal file
26
hGameTest/src/assets/SpriteSheet.hx
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package assets;
|
||||||
|
|
||||||
|
import openfl.geom.Point;
|
||||||
|
import openfl.geom.Rectangle;
|
||||||
|
import openfl.display.BitmapData;
|
||||||
|
import openfl.display.Bitmap;
|
||||||
|
class SpriteSheet{
|
||||||
|
public static var spriteSheetArray:Array<SpriteSheet> = [];
|
||||||
|
public var sprites:Array<BitmapData> = [];
|
||||||
|
public function new(bmp:BitmapData = null, sprWidth:Int = 16, sprHeight:Int = 16){
|
||||||
|
spriteSheetArray.push(this);
|
||||||
|
var columns:Int = cast((bmp.width / sprWidth),Int);
|
||||||
|
var rows:Int = cast((bmp.height / sprHeight),Int);
|
||||||
|
//trace("columns:"+columns);
|
||||||
|
//trace("rows"+rows);
|
||||||
|
for(i in 0...rows){
|
||||||
|
for (j in 0...columns){
|
||||||
|
var bmpd:BitmapData = new BitmapData(sprWidth, sprHeight,true,0x00000000);
|
||||||
|
var rect:Rectangle = new Rectangle(j*sprWidth,i*sprHeight,sprWidth,sprHeight);
|
||||||
|
bmpd.copyPixels(bmp, rect, new Point(0,0));
|
||||||
|
sprites.push(bmpd);
|
||||||
|
//trace("i:"+i+",j:"+j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
44
hGameTest/src/assets/TextureData.hx
Normal file
44
hGameTest/src/assets/TextureData.hx
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package assets;
|
||||||
|
|
||||||
|
import openfl.Assets;
|
||||||
|
import haxe.Json;
|
||||||
|
|
||||||
|
typedef TexturesV1={
|
||||||
|
var dataScheme:String;
|
||||||
|
var version:Int;
|
||||||
|
var textureData:{
|
||||||
|
var spriteSheets:Array<{
|
||||||
|
var sheetNamekeke:String;
|
||||||
|
var path:String;
|
||||||
|
var sheetDataPath:String;
|
||||||
|
var explicitDimensions:Bool;
|
||||||
|
var tileDimensions:{
|
||||||
|
var width:Int;
|
||||||
|
var height:Int;
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
var sprites:Array<{
|
||||||
|
var spriteName:String;
|
||||||
|
var path:String;
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class TextureData{
|
||||||
|
public static var textures:Array<Any> = [];
|
||||||
|
public static function parseConfig(path:String = "data/textures.json"){
|
||||||
|
var DATA:TexturesV1;
|
||||||
|
var loadedData:String = Assets.getText(path);
|
||||||
|
var jsondata = Json.parse(loadedData);
|
||||||
|
DATA = jsondata;
|
||||||
|
//var test:String = File.getContent(test.txt);
|
||||||
|
trace(DATA);
|
||||||
|
/*typedef DataModal=
|
||||||
|
{
|
||||||
|
var ID:Int;
|
||||||
|
var NAME:String;
|
||||||
|
var TAGS:Array<String>;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
47
hGameTest/src/assets/schema/HTexSchema.hx
Normal file
47
hGameTest/src/assets/schema/HTexSchema.hx
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package assets.schema;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef TileSetGenericV1={
|
||||||
|
var baseTexture:String;
|
||||||
|
var tiles:Array<String>;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef TileSetAnimatedV1={
|
||||||
|
var baseTexture:String;
|
||||||
|
var animations:Array<{
|
||||||
|
var animName:String;
|
||||||
|
var sequenceStart:Int;
|
||||||
|
var sequenceEnd:Int;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
typedef TextureDataV1={
|
||||||
|
var texName:String;
|
||||||
|
var texType:String;
|
||||||
|
var atlas:{
|
||||||
|
var atlasType:String;
|
||||||
|
var tileSize:{
|
||||||
|
var x:Int;
|
||||||
|
var y:Int;
|
||||||
|
},
|
||||||
|
var tileSetGeneric:TileSetGenericV1;
|
||||||
|
var tileSetAnimated:TileSetAnimatedV1;
|
||||||
|
}
|
||||||
|
var path:String;
|
||||||
|
var sheetDataPath:String;
|
||||||
|
var explicitDimensions:Bool;
|
||||||
|
var tileDimensions:{
|
||||||
|
var width:Int;
|
||||||
|
var height:Int;
|
||||||
|
};
|
||||||
|
var sprites:Array<{
|
||||||
|
var spriteName:String;
|
||||||
|
var path:String;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef TexV1={
|
||||||
|
var dataScheme:String;
|
||||||
|
var version:Int;
|
||||||
|
var textureData:TextureDataV1;
|
||||||
|
}
|
||||||
12
hGameTest/src/assets/tilesets/Sequence.hx
Normal file
12
hGameTest/src/assets/tilesets/Sequence.hx
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package assets.tilesets;
|
||||||
|
|
||||||
|
import openfl.display.BitmapData;
|
||||||
|
class Sequence{
|
||||||
|
public var bitmaps:Array<BitmapData> = [];
|
||||||
|
public var name:String = "";
|
||||||
|
public var currentFrame = 0;
|
||||||
|
public function new(_name:String, _bitmaps:Array<BitmapData>){
|
||||||
|
name = _name;
|
||||||
|
bitmaps = _bitmaps;
|
||||||
|
}
|
||||||
|
}
|
||||||
10
hGameTest/src/assets/tilesets/TilesetAnimated.hx
Normal file
10
hGameTest/src/assets/tilesets/TilesetAnimated.hx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package assets.tilesets;
|
||||||
|
|
||||||
|
import assets.schema.HTexSchema;
|
||||||
|
|
||||||
|
class TilesetAnimated{
|
||||||
|
public var sequences:Array<Sequence> = [];
|
||||||
|
public function new(){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
8
hGameTest/src/assets/tilesets/TilesetGeneric.hx
Normal file
8
hGameTest/src/assets/tilesets/TilesetGeneric.hx
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package assets.tilesets;
|
||||||
|
|
||||||
|
|
||||||
|
class TilesetGeneric {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user