1. Right-click on "SourceCode" folder and select "New"
2. Enter the name SpriteCustom.cs
3. Replace the whole text of the file with this:
using System.ComponentModel;
using System.Diagnostics;
public abstract partial class SpriteBase : GeneralRules
{
/// <summary>
/// Determine if this sprite is currently visible
/// </summary>
/// <returns>True if the sprite is active and any part of the
/// sprite insersects with the currently displayed area of the
/// map layer it is on, otherwise false.</returns>
[Description("Determine if this sprite is currently visible")]
public bool IsVisible()
{
return isActive && layer.IsSpriteVisible(this);
}
}
Now when you go to edit Sprite rules, you will see a new rule "IsVisible".
If you are creating the game to also work in a browser (if you want to use the "Export to HTML5 Code" command in the file menu), then you must also do this:
1. Right-click on "SourceCode" and select "New"
2. Enter the name SpriteCustom.js (notice this name ends with ".js" instead of ".cs")
3. Add this to the file:
Sprite.prototype.isVisible = function() {
return this.isActive && this.layer.isSpriteVisible(this);
};
4. Right-click on "SourceCode" and select "New"
5. Enter the name MapLayerCustom.js
6. Add this to the file:
MapLayer.prototype.isSpriteVisible = function(sprite) {
if (!sprite.isActive)
return -1;
var x1 = Math.floor(sprite.x);
var w1 = sprite.getSolidWidth();
var x2 = -this.currentX;
var w2 = viewWidth;
var y1 = Math.floor(sprite.y);
var h1 = sprite.getSolidHeight();
var y2 = -this.currentY;
var h2 = viewHeight;
if ((x1 + w1 > x2) && (x2 + w2 > x1) && (y1 + h1 > y2) && (y2 + h2 > y1))
return true;
return false;
}
Now your rules will work in a web browser game too.