Game definition jsons - Sprites and Textures (graphics.json)

Learn the .json format
used to define characteristics of units and other game elements
Post Reply
Stratego (dev)
Site Admin
Posts: 15741
Joined: Fri Apr 25, 2014 9:28 pm

Game definition jsons - Sprites and Textures (graphics.json)

Post by Stratego (dev) »

Here is the "sprites and textures definition" json: graphics.json


there are two listst:
- sprites (includes its own texture) - used for eg. projectiles (flying arrow) or spot animations (fireball explosion)
- textures - used for action icons, button images, indicator images

Code: Select all


{
	"sprites": [                                  
		{			
			"idString": "SPRITE_SPELL_SPOT_ANIM_SWORD_WHIRLWIND",                    - sprite name
			"addRotation": 0.50f,                                                                              - base rotation (eg. arrow direction) 0 means do not rotate me (so set 0.01 if you want to add 0 degree)
			"onLayer": "HIGHLIGHT",			                                                     
			"texture": { 
				"imgName": "96_anim_action_sword_whirlwind.png",                        - image asset filename
				"cropToRect": {"bottom": 20,"left": 10,"right": 20,"top": 10},               - you can cut a part of it to be the texture.
				"imgColumns": 4,                                                                             - 1 = single image, more: animation
				"animFrameDuration":40,								      - animation case: the time each image is shown (milli sec) - if 0 and decor sprite than it will be calculated from the animation or attack/move and last to the end of it.
                               "animFrameDurations": eg: [6000,200,200,200,200,200,200,200,200,200], sets the frame duration for all frames	in millisecs (if set, animFrameDuration is omitted)
				"animLoopCount":0,				                                              - animation case: how amny times to play the animation (§ = loop forever)
                                "translateX":-20, //in case of decor animations like sword slash, move decor, you can define translation where to draw the image from the default unit tile top-left position
                                "translateY":-10, //in case of decor animations like sword slash, move decor, you can define translation where to draw the image from the default unit tile top-left position
                                "fadeOutDurationSec":0.5, //on the end of an animation (eg. attack or move decor) how much sec time to fade out eg. 0.5 sec
				
				"withColoring": false,                                                                       - if it is a "player color" relevant image
				"soundPackIdString": "SOUND_PACK_WHIRLWIND_ATTACK"                 - in case of spot animation  - this can be the sound of animation. (fireball explosion )
			}
		},
		{			
			"idString": "SPRITE_ACTION_CANNONBALL",                                             - these are the individual textures (being no sprites), the definition is exactly same as above the texture within the sprite case.
			"addRotation": 0f,
			"onLayer": "HIGHLIGHT",	
			"postAnimIdString": "SPRITE_EXPLOSION",			                            - you can set another sprite that should be played on the end of this sprite anumation (like an explosion after the cannonball reach target)
			"texture": { 
			        "idString": "TEXTURE_ACTION_CANNONBALL",
				"imgName": "32_arrow_cannon_ball.png",
				"imgColumns": 1,
				"withColoring": false,
				"soundPackIdString": "SOUND_PACK_WHIRLWIND_ATTACK"
				 
			}
		}

	],
	"textures": [
		{
			"idString": "XXTEXTURE_ACTION_CANNONBALL",
			"imgColumns": 1,
			"imgName": "32_arrow_cannon_ball.png",
			"soundPackIdString": "SOUND_UNIT_ATTACK_CANNON",			
			"withColoring": false
		}
	]
	
	
	
	
}

you can reference the texture and sprite "idString" in other jsons (eg. in effects.json)
Stratego (dev)
Site Admin
Posts: 15741
Joined: Fri Apr 25, 2014 9:28 pm

Re: Game definition jsons - Sprites and Textures

Post by Stratego (dev) »

new values can be set on textures

Code: Select all

...
				"animFrameDuration":40,								      - animation case: the time each image is shown (milli sec)
				"animLoopCount":0,				                                              - animation case: how much time to play the animation
...
Stratego (dev)
Site Admin
Posts: 15741
Joined: Fri Apr 25, 2014 9:28 pm

Re: Game definition jsons - Sprites and Textures

Post by Stratego (dev) »

new option for sprites:
"postAnimIdString": "SPRITE_EXPLOSION",


you can set anoher sprite that should be played on the end of this sprite (like an explosion after the cannonball reach target)


available for all games AOF/AOW/AOS
now i use it to have explosion for AOW tanks and ship attacks - target ill get an explision animation when the bullet reaches target.
User avatar
L4cus
Posts: 2358
Joined: Fri Jan 31, 2020 7:51 pm
Location: Perú

Re: Game definition jsons - Sprites and Textures (graphics.json)

Post by L4cus »

oh i found what i needed! thnx
Extra ecclesiam nulla salus...
AOD, a new variant...
viewforum.php?f=230
Midonik
Posts: 5325
Joined: Mon Sep 05, 2016 5:27 pm
Location: Poland

Re: Game definition jsons - Sprites and Textures (graphics.json)

Post by Midonik »

What about the sounds tho?
Support new AoS variant, Age of Galaxy: http://ageofstrategy.net/viewforum.php? ... 608408ebc8
All help will be welcome.
Stratego (dev)
Site Admin
Posts: 15741
Joined: Fri Apr 25, 2014 9:28 pm

Re: Game definition jsons - Sprites and Textures (graphics.json)

Post by Stratego (dev) »

change, so added comment to this:
"animFrameDuration":40, - animation case: the time each image is shown (milli sec) - if 0 and decor sprite than it will be calculated from the animation or attack/move and last to the end of it (eg. sword-swing animation).
Stratego (dev)
Site Admin
Posts: 15741
Joined: Fri Apr 25, 2014 9:28 pm

Re: Game definition jsons - Sprites and Textures (graphics.json)

Post by Stratego (dev) »

new properties currently used on all types of decor animations

"translateX":-20, //in case of decor animations like sword slash, move decor, you can define translation where to draw the image from the default unit tile top-left position
"translateY":-10, //in case of decor animations like sword slash, move decor, you can define translation where to draw the image from the default unit tile top-left position
"fadeOutDurationSec":0.5, //on the end of an animation (eg. attack or move decor) how much sec time to fade out eg. 0.5 sec
Stratego (dev)
Site Admin
Posts: 15741
Joined: Fri Apr 25, 2014 9:28 pm

Re: Game definition jsons - Sprites and Textures (graphics.json)

Post by Stratego (dev) »

new

"animFrameDurations": eg: [6000,200,200,200,200,200,200,200,200,200], sets the frame duration for all frames in millisecs (if set, animFrameDuration is omitted)
Post Reply

Return to “Game Definition .JSON”