Spherical forums

Sphere Development => Sphere Support => Topic started by: williammah on May 03, 2013, 03:04:14 am

Title: Bind an image to the camera
Post by: williammah on May 03, 2013, 03:04:14 am
Is there a way to bind an image to the camera?
Title: Re: Bind an image to the camera
Post by: Radnen on May 03, 2013, 04:00:31 am
In the map engine there are render scripts. Here is a quick example of how to achieve this:

Code: (javascript) [Select]

function game()
{
    CreatePerson("player", "some_sprite.rss", false);
    // ...

    SetRenderScript("MyRender();");

    //...
    MapEngine("some_map.rmp");
}

var my_image = LoadImage("some_image.png");

function MyRender()
{
    my_image.blit(0, 0); // draws the image at location 0, 0, following the camera.
}


Render scripts are, in a way, attached to the camera as in they move when it moves. This is useful for showing HUD's and other pieces of info.
Title: Re: Bind an image to the camera
Post by: DaVince on May 05, 2013, 04:27:26 pm
Rather than saying they follow the camera, it might be better to say it's not dependent on the map engine's camera at all. Thus, position (0,0) is the top-left of the screen no matter what; the map engine and camera don't factor in at all (except for the fact that a thing like a render script is a map engine thing, I suppose).