Page 1 of 1

Cut off Graphics

Posted: Sun Mar 26, 2017 3:48 pm
by Petrenko
Heyho,

i made a rifleman.

The problem is, some animations got cut off and i think it got something to do with the shifting in the animations.

Is there a formula one could use?

I based him off the small biter.

Here you got the animation:

Code: Select all

function rus_rifleman_1_runanimation(scale)
  return
  {
    layers=
    {
      {
        width = 190,
        height = 125,
        frame_count = 8,
        direction_count = 16,
        shift = { 0.0, 0.0},
        scale = scale,
        stripes =
        {
         {
          filename = "__robotarmy__/graphics/entity/rus_rifleman_1/rus_rifleman_1_run.png",
          width_in_frames = 8,
          height_in_frames = 16,
         },
         {
          filename = "__robotarmy__/graphics/entity/rus_rifleman_1/rus_rifleman_1_run.png",
          width_in_frames = 8,
          height_in_frames = 16,
         }
        }
      }
	}
  }
end
Here you got himself:

Code: Select all

data:extend(
{
  {
    type = "unit",
    name = "rus_rifleman_1",
    icon = "__base__/graphics/icons/small-biter.png",
    flags = {"placeable-player", "placeable-enemy", "placeable-off-grid", "breaths-air"},
    max_health = 15,
    order = "b-b-a",
    subgroup="creatures",
	minable = {hardness = 0.1, mining_time = 0.1, result = "rus_rifleman_1_item"},
    healing_per_tick = 0.01,
    collision_box = {{-0.5, -0.5}, {0.5, 0.5}},
    selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
    attack_parameters =
    {
      type = "projectile",
      range = 12.5,
      cooldown = 35,
      ammo_category = "melee",
      ammo_type = make_unit_melee_ammo_type(6),
      sound = make_biter_roars(0.5),
      animation = rus_rifleman_1_attackanimation(riflemanscale)
    },
    vision_distance = 30,
    movement_speed = 0.1,
    distance_per_frame = 0.4,
    pollution_to_join_attack = 200,
    distraction_cooldown = 300,
    dying_explosion = "blood-explosion-small",
    dying_sound =  make_biter_dying_sounds(1.0),
    working_sound =  make_biter_calls(0.7),
    run_animation = rus_rifleman_1_runanimation(riflemanscale)
  }
}
)
Thanks in advance for any help =)

Re: Cut off Graphics

Posted: Tue Mar 28, 2017 2:17 pm
by Petrenko
I'm adding my spritesheet for reference.

Re: Cut off Graphics

Posted: Tue Mar 28, 2017 4:48 pm
by 321freddy
What exactly is getting cut off?
Shift is used to align the sprite correctly in case it is off center but since you only have one layer in your animation this shouldn't cause any real issue.

Also why are you declaring the same run animation file twice inside stripes in the runanimaton function.
The stripes parameter is used when you want to combine multiple source images because one would be too large. So you should replace the whole stripes section with the following line:

Code: Select all

filename = "__robotarmy__/graphics/entity/rus_rifleman_1/rus_rifleman_1_run.png",

Re: Cut off Graphics

Posted: Wed Mar 29, 2017 11:48 am
by Petrenko
Heyho,

thank you for having a look.

I got rid of the stripes and also killed the shift.

Still it cuts off on the left. It's hard to describe.

Have a look:

Re: Cut off Graphics

Posted: Wed Mar 29, 2017 12:47 pm
by prg
Can't repro.
rifleman.jpg
rifleman.jpg (17.04 KiB) Viewed 2596 times
Maybe try deleting crop-cache.dat, might help if you were using a different image with the same name previously and now things got confused somehow.

Re: Cut off Graphics

Posted: Wed Mar 29, 2017 12:49 pm
by 321freddy
Ok I just tested it with your code and it works perfectly on my side:
Image

Sorry I have no idea what the problem is, maybe it's your computer or some internal factorio bug. Maybe your game ran out of video memory?
Here is the data.lua code I used to test it, I only changed some the image paths and experimented a little with shift, maybe you can spot the difference:

Code: Select all

function rus_rifleman_1_runanimation(scale)
  return
  {
    layers=
    {
      {
        width = 190,
        height = 125,
        frame_count = 8,
        direction_count = 16,
        shift = { scale * 1.5, scale * -0.5},
        scale = scale,
        filename = "__test-mod__/rus_rifleman_1_run.png",
      }
   }
  }
end

riflemanscale = 1

data:extend{
  {
    type = "unit",
    name = "rus_rifleman_1",
    icon = "__base__/graphics/icons/small-biter.png",
    flags = {"placeable-player", "placeable-enemy", "placeable-off-grid", "breaths-air"},
    max_health = 15,
    order = "b-b-a",
    subgroup="creatures",
    minable = {hardness = 0.1, mining_time = 0.1, result = "rus_rifleman_1"},
    healing_per_tick = 0.01,
    collision_box = {{-0.5, -0.5}, {0.5, 0.5}},
    selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
    attack_parameters =
    {
      type = "projectile",
      range = 12.5,
      cooldown = 35,
      ammo_category = "melee",
      ammo_type = make_unit_melee_ammo_type(6),
      sound = make_biter_roars(0.5),
      animation = rus_rifleman_1_runanimation(riflemanscale)
    },
    vision_distance = 30,
    movement_speed = 0.1,
    distance_per_frame = 0.4,
    pollution_to_join_attack = 200,
    distraction_cooldown = 300,
    dying_explosion = "blood-explosion-small",
    dying_sound =  make_biter_dying_sounds(1.0),
    working_sound =  make_biter_calls(0.7),
    run_animation = rus_rifleman_1_runanimation(riflemanscale)
  },
  {
		type = "item",
		name = "rus_rifleman_1",
		icon = "__base__/graphics/icons/small-biter.png",
		flags = {"goes-to-quickbar"},
		subgroup = "creatures",
		order = "a",
		stack_size = 100,
		place_result = "rus_rifleman_1",
	},
	{
		type = "recipe",
		enabled = true,
		ingredients = {
			{ "copper-cable", 1 }
		},
		name = "rus_rifleman_1",
		requester_paste_multiplier = 4,
		result = "rus_rifleman_1",
		result_count = 1
	}
}

Re: Cut off Graphics

Posted: Wed Mar 29, 2017 3:18 pm
by Petrenko
Heyho,

i duplicated the unit to spawn as an enemy for my mod and that got no cut off edges.

Where can i find the cropcache.dat? I guess this could be the solution.

Edit: Nevermind. Found it. And worked. I wasn't aware this even existed. I'm an idiot. Thank you very much!