Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

[GM7] Room changing


BOB_ROX

Recommended Posts

If any of you play sonic chronicles the dark brotherhood you'd see these icons that pop up near doors and stuff and you use the stylis pen to click it, Im trying to get that to work when near the door of tails workshop so you can go in and out. So basically it switches rooms. But I want it so its mouse click.

Heres what I got so far for the draw event, But even this isnt working how I want it too

if distance_to_object(objPlayer) = 50
image_index=1
if distance_to_object(objPlayer) = 100
image_index=0[/CODE]

Can anyone help me to get it to work?

Link to comment
Share on other sites

Well, that will only work if you are exactly 50 pixels or exactly 100 pixels away. Try doing it like this:

if (distance_to_object(objPlayer) < 50)
{image_index=1}
if (distance_to_object(objPlayer) > 49 && < 100)
{image_index=0}

Link to comment
Share on other sites

if (distance_to_object(objPlayer) < 10)
{image_index=1}
if (distance_to_object(objPlayer) > 9 && 50)
{image_index=0}[/CODE]

Thats what I got now, As I said I had to remove that < sign on the second line coz an error popped up with it saying Unexpected symbol, And as I also said I tried changing the numbers in the code coz when I first used it. It didnt show. So Yeah.

Link to comment
Share on other sites

if (distance_to_object(objPlayer) < 10)
{image_index=1}
if (distance_to_object(objPlayer) > 9 && 50)
{image_index=0}[/CODE]

Thats what I got now, As I said I had to remove that < sign on the second line coz an error popped up with it saying Unexpected symbol, And as I also said I tried changing the numbers in the code coz when I first used it. It didnt show. So Yeah.

The second line of that code would pop up all kinds of errors because the syntax is wrong. It should look like:

[CODE]if (distance_to_object(objPlayer) < 10)
{image_index=1}
if (distance_to_object(objPlayer) > 9 && distance_to_object(objPlayer) < 50)
{image_index=0}[/CODE]

Link to comment
Share on other sites

Maybe another function would yield better results. Try something like this:

if ( instance_exists(objPlayer) ) {
    if( point_distance(x, y, objPlayer.x, objPlayer.y ) &lt;= 50 )image_index = 1;
    else image_index = 0;
}

The first line is just to ensure that no errors come up during the start or end of a room.

Link to comment
Share on other sites

Im sorry but that didnt work either, Idk why it isnt working, I swear I only got a code that only shows draw and thats the code Nothing else. Coz I know how I want the mouse click to work but I havent got that in the object yet, Im just worried about the appearing in the draw event.

Link to comment
Share on other sites

Well Im guessing not, Coz I got the code in the draw event. And the sprite has 2 sub images, One thats invisible and one that is not, So its supposed to start out as invisible I kinda tried to get it so that when your close enough to it, It changes it. Or draws it and stuff. but since it didnt work I tried switching the 2 sub images around and it still doesnt come up with ANYTHING, No sprite, No nothing.

Link to comment
Share on other sites

I can't believe I missed the fact that you put the code in the draw event.

As for your new problem, global variables and creation codes should be able to solve the problem.

First off, make 2 global variables (called 'global.teleport_x' and 'global.teleport_y') when you start the game.

Next, go to the room editor of every map the player will be in, go to Settings > Creation Code, and add:

instance_create(global.teleport_x, global.teleport_y, objPlayer);

Then, press ctrl+right_click on your button object and select 'Creation Code', then add:

teleport_x = a number;
teleport_y = a number;

This will give each button a unique set of customize without having to make new objects for each teleporter. Make sure those 2 variables are NOT defined in the button object's Create Event or it won't work. Now its just a case of adding the following code in the button's Mouse click code:

global.teleport_x = teleport_x;
global.teleport_y = teleport_y;

That should do it.

Link to comment
Share on other sites

I got 2 errors when I did what you told me

___________________________________________

ERROR in

action number 1

of Step Event

for object objPlayer:

Error in code at line 2:

if (player_collision_bottom_object(x, y, relative_angle, maskBig, objSpikeUp))

at position 43: Unknown variable relative_angle

and the other

___________________________________________

ERROR in

action number 1

of Step Event

for object objBridge:

Error in code at line 23:

|| !player_handle.ground) continue;

at position 33: Unknown variable ground

What do I do about these?

Link to comment
Share on other sites

This happens if the variables aren't defined in the create event, but the step event needs to use those missing variables immediately. This is usually a parenting problem.

I'm not sure though... the template you use might handle spawning in a different way, where just using the "instance_create(x,y,obj)" function to spawn a player character doesn't complete the process.

Link to comment
Share on other sites

That depends on the engine you use. First of all, make sure you know that all the variables (in this case 'ground' and 'relative_angle') are actually defined in the Create Event of objPlayer (or the child object if objPlayer has them). Then hunt down the code that normally spawns the player, and replicate that in the room Creation Code.

Apart from that, I've got nothing without taking a closer look myself.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...