Title sequences

Non-platform specific questions.

Title sequences

Postby draxido » Sun Feb 14, 2010 7:45 pm

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) :]
Attachments
game test.rar
(996.98 KiB) Downloaded 52 times
draxido
 
Posts: 18
Joined: Mon Feb 01, 2010 7:36 pm
Score: 0 Give a positive score

Re: Title sequences

Postby DST » Sun Feb 14, 2010 8:08 pm

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.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Title sequences

Postby draxido » Sun Feb 14, 2010 8:20 pm

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. :]
draxido
 
Posts: 18
Joined: Mon Feb 01, 2010 7:36 pm
Score: 0 Give a positive score

Re: Title sequences

Postby DST » Sun Feb 14, 2010 8:27 pm

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.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Title sequences

Postby draxido » Mon Feb 15, 2010 3:07 am

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?
draxido
 
Posts: 18
Joined: Mon Feb 01, 2010 7:36 pm
Score: 0 Give a positive score

Re: Title sequences

Postby Bee-Ant » Mon Feb 15, 2010 6:45 am

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
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Title sequences

Postby draxido » Mon Feb 15, 2010 1:42 pm

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));
draxido
 
Posts: 18
Joined: Mon Feb 01, 2010 7:36 pm
Score: 0 Give a positive score

Re: Title sequences

Postby Bee-Ant » Mon Feb 15, 2010 3:49 pm

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
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Title sequences

Postby draxido » Mon Feb 15, 2010 4:10 pm

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?
draxido
 
Posts: 18
Joined: Mon Feb 01, 2010 7:36 pm
Score: 0 Give a positive score

Re: Title sequences

Postby Bee-Ant » Mon Feb 15, 2010 4:25 pm

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...
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Title sequences

Postby draxido » Mon Feb 15, 2010 5:07 pm

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 :/
Attachments
game test.rar
(1012.56 KiB) Downloaded 54 times
draxido
 
Posts: 18
Joined: Mon Feb 01, 2010 7:36 pm
Score: 0 Give a positive score

Re: Title sequences

Postby Bee-Ant » Thu Feb 18, 2010 6:35 am

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.
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Title sequences

Postby draxido » Sun Feb 28, 2010 5:12 pm

Hey, sorry for this again.

what would the code be for the player?
I still cant figure it out :/
draxido
 
Posts: 18
Joined: Mon Feb 01, 2010 7:36 pm
Score: 0 Give a positive score

Re: Title sequences

Postby Bee-Ant » Sun Feb 28, 2010 6:48 pm

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
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron