set_x_offset(v.x);
set_y_offset(v.y);
}
-
+
std::string draw_target_s = "normal";
reader.get("draw-target", draw_target_s);
if (draw_target_s == "normal") draw_target = DrawingContext::NORMAL;
if (draw_target_s == "lightmap") draw_target = DrawingContext::LIGHTMAP;
+ if (reader.get("alpha", alpha)) {
+ current_alpha = alpha;
+ }
+
reader.get("width", width);
reader.get("height", height);
if(width < 0 || height < 0)
if (amt > 0) current_alpha = std::min(current_alpha + amt, alpha);
if (amt < 0) current_alpha = std::max(current_alpha + amt, alpha);
}
- if (current_alpha < 0.25) set_solid(false);
+ if ((alpha < 0.25) && (current_alpha < 0.25)) set_solid(false);
+ if ((alpha > 0.75) && (current_alpha > 0.75)) set_solid(true);
}
// if we have a path to follow, follow it
void
TileMap::draw(DrawingContext& context)
{
+ // skip draw if current opacity is set to 0.0
+ if (current_alpha == 0.0) return;
+
context.push_transform();
context.push_target();
context.set_target(draw_target);
TileMap::expose(HSQUIRRELVM vm, SQInteger table_idx)
{
if (name.empty()) return;
- if (!walker.get()) return;
Scripting::TileMap* interface = new Scripting::TileMap(this);
expose_object(vm, table_idx, interface, name, true);
}
TileMap::unexpose(HSQUIRRELVM vm, SQInteger table_idx)
{
if (name.empty()) return;
- if (!walker.get()) return;
Scripting::unexpose_object(vm, table_idx, name);
}
width = new_width;
}
-void
-TileMap::set_solid(bool solid)
+void
+TileMap::set_solid(bool solid)
{
this->solid = solid;
}
}
}
-void
+void
TileMap::fade(float alpha, float seconds)
{
this->alpha = alpha;
this->remaining_fade_time = seconds;
}
+
+void
+TileMap::set_alpha(float alpha)
+{
+ this->alpha = alpha;
+ this->current_alpha = alpha;
+ this->remaining_fade_time = 0;
+ if (current_alpha < 0.25) set_solid(false);
+ if (current_alpha > 0.75) set_solid(true);
+}
+
+float
+TileMap::get_alpha()
+{
+ return this->current_alpha;
+}
+
IMPLEMENT_FACTORY(TileMap, "tilemap");