Page 1 of 1

Title sequences

PostPosted: Sun Feb 14, 2010 7:45 pm
by draxido
Hello again.

Im having some trouble moving my view actor from the title sequence to the game.
I cant seem to assign the view to move to the correct co ordinates for where the player actor is.
Ive done what I think needs to be done, but it doesnt seem to want to work.
Any help would be greaty appreciated :]

Ive added the game demo, just incase anyone needs to see it for some reason.
(I must warn you, its not pretty) :]

Re: Title sequences

PostPosted: Sun Feb 14, 2010 8:08 pm
by DST
When you use parent, it adds the parent's attributes to the child.

So when you move view to playerx and playery and also change view to become player's child, view is moving to twice the xy you intend.

A few suggestions:

1. Don't use events in a list like that, instead, on mousebuttonup, just have one event, script editor.
Using the variables/functions tab at the bottom of the script window, you can add all the events like normal, but they'll be inside the script window. Then you can edit all the events in one place, instead of having to choose them each off the menu each time you want to use them.

2. Don't parent view to player. Instead, use player>draw actor>
Code: Select all
view.x=x-320;
view.y=y-240;


Then you won't have problems with where view moves to anymore. If you want to turn it on or off, create a global integer variable, and have this in the draw actor for player:
Code: Select all
if(variable==1){
view.x=x-320;
view.y=y-240;
}


The variable will start on 0, so you can change it to 1 on newgame>mousebuttonup. In that case, you wouldn't even have to issue a view >moveto command, because player would start doing it the moment the variable became 1.

Re: Title sequences

PostPosted: Sun Feb 14, 2010 8:20 pm
by draxido
hey, thanks for the response.

Ive only been at this for 3-4 days so, Im not really used to how the scripting really works just yet.

With this code, is that resizing the view? or what? I dont quite understand what its for :/

Code: Select all
view.x=x-320;
view.y=y-240;


I will take your advice on board though, and try to keep everything scripted. :]

Re: Title sequences

PostPosted: Sun Feb 14, 2010 8:27 pm
by DST
You are simply setting a variable there.

view.x= this tells the game to set view.x to whatever comes after the = sign, in this case, player.x-320. ( you don't need to use player. in front of x inside a player script; just x is enough).

Variables always reference the actor they were created in, unless you specify otherwise.

So x refers to the x position of whatever actor the script is in.

I subtracted the numbers because view.x and view.y are the upper left corner of view, while player.x and player.y are the center of player. This is true for all wireframe actors (filled, view, canvas, and wireframe).

so -320, -240 puts player in the center of the view.

Re: Title sequences

PostPosted: Mon Feb 15, 2010 3:07 am
by draxido
Thanks a million mate, Its working perfectly now *Touch wood*
The only issue left is, now that i have the view.x code, the screen keeps juttering up and down, but I susspect this is due to my sprites, as oppose to the code itself.

But thanks for the help, really appreciate it :]

**Edit**

Ive just tried altering the character sprite + the ground sprite, but i still get this vibration thing, any idea what could be causing it?

Re: Title sequences

PostPosted: Mon Feb 15, 2010 6:45 am
by Bee-Ant
Using DST code may make vibration effect on some condition, try this code on :
1. If you put that code on Player->DrawActor :
Code: Select all
view.x=max(x-10,min(x,x+10));
view.y=max(y-10,min(y,y+10));

2. If you put that code on view->DrawActor :
Code: Select all
x=max(Player.x-10,min(x,Player.x+10));
y=max(Player.y-10,min(y,Player.y+10));

You can change the 10 to any value you want :D
Hope this helps :D

Re: Title sequences

PostPosted: Mon Feb 15, 2010 1:42 pm
by draxido
Hey Bee,

the code you suggested puts the view actor, centering it to my player actor, so its in the topleft hand corder of the screen. It also still vibrates :/
Am i doing something wrong?

I put the code on the player - drawactor like you said, and changed the 10 values to -320 and - 240 to center it.
It looks like this
Code: Select all
view.x=max(x-320,min(x,x+240));
view.y=max(y-240,min(y,y+320));

Re: Title sequences

PostPosted: Mon Feb 15, 2010 3:49 pm
by Bee-Ant
Oh, sorry sorry i forgot to add the half width...
So, you put it in view-DrawActor?
Then, the right code should be like this...

x=max(Player.x-(width/2)-10,min(x,Player.x-(width/2)+10));
y=max(Player.y-(height/2)-10,min(y,Player.y-(height/2)+10));

This is worked with any size of view :D

Re: Title sequences

PostPosted: Mon Feb 15, 2010 4:10 pm
by draxido
awesome, no more vibrating! :]

Only thing is, the view only goes one way, which is right. How can i make it go left when the character moves that way?

Re: Title sequences

PostPosted: Mon Feb 15, 2010 4:25 pm
by Bee-Ant
What are you talking about?
Im testing it right now.
It works fine on me...
Just check carefully, there may be something wrong with your code...

Re: Title sequences

PostPosted: Mon Feb 15, 2010 5:07 pm
by draxido
Ive just tried making it from scratch, and i get the same problem.
I put the code on the player + changed it to how i thought it needed to be ( i think its right)

Heres the file so you can see what i mean.

Sorry for this, I feel bad for constantly asking for help :/

Re: Title sequences

PostPosted: Thu Feb 18, 2010 6:35 am
by Bee-Ant
Thats why I said, check carefully your code...
You just mix up the code for player and view. They're different. Dont mix them up.
If you want to put it in view, use the view code. If player, then the player code.

Re: Title sequences

PostPosted: Sun Feb 28, 2010 5:12 pm
by draxido
Hey, sorry for this again.

what would the code be for the player?
I still cant figure it out :/

Re: Title sequences

PostPosted: Sun Feb 28, 2010 6:48 pm
by Bee-Ant
Bee-Ant wrote:1. If you put that code on Player->DrawActor :
Code: Select all
view.x=max(x-10,min(x,x+10));
view.y=max(y-10,min(y,y+10));


But change -10 to view.width/2-10 and +10 to view.width/2+10