Page 1 of 1

Hi I'm new here. I have a question about camera..

PostPosted: Sun Jun 22, 2008 4:03 am
by rp0094
Hi. I've learned at least 20% of this program thus far, but am nowhere near having a full grasp on anything 20%, other than some minor basic things.

I noticed parts of the built-in tutorials were slightly bugged. The tutorial for "Having the Camera follow Actor on the Moving Screen", seemed to end with a bug. The cursor seemed to have accidently clicked the wrong Parent, and got the notice for it, but then didn't do anything for about 1 minute, until it said the tutorial ended.

I am just trying to set the camera to follow the main "player" as it moves along the screen.

I've tried making the "Player" the parent of the "View", and then I tried making the "View" the parent of the "Score", but no combination and attempt worked. Everytime I load the game, and I move the character, it just walks off the screen, and the camera apparently doesn't follow it.

Help very much appreciated. Thanks :).

(Also, I am very sure this is possible, but to make sure, you're able to import your own textures, character gifs, etc., right?)

Re: Hi I'm new here. I have a question about camera..

PostPosted: Sun Jun 22, 2008 4:48 am
by DST
IF you set view to be the child of player, then view must follow player.

If it isn't, then you have some kind of glitch.

Try unparenting the view, and add a draw actor to view:
Code: Select all
x=player1.x-320;


This is for a game that is 640x480, we subtract half the width (because view 0 starts in upper left hand corner of view).
and player1 is what i always call player1; you can call it whatever you like. (i think you said "Player").

I make sure never to use capital letters with names in GE. You will type them many times. Shift is just one more key to press, for no real reason.

Re: Hi I'm new here. I have a question about camera..

PostPosted: Sun Jun 22, 2008 7:48 pm
by Bee-Ant
Or use this code for any size of view
Code: Select all
x=player.x-(width/2);
y=player.y-(height/2);

Re: Hi I'm new here. I have a question about camera..

PostPosted: Sun Jun 22, 2008 10:04 pm
by Fuzzy
improve the speed some: make two global variables, called HalfWidth and HalfHeight. in create actor event for view put this:

Code: Select all
HalfWidth = width/2;
HalfHeight = height/2;


and then for Bee-Ants code put these lines instead

Code: Select all
x=player.x-HalfWidth;
y=player.y-HalfHeight;


Why? you only need to do the math once per game instead of every draw event!

Re: Hi I'm new here. I have a question about camera..

PostPosted: Mon Jun 23, 2008 9:21 pm
by catacomber
To answer your question about whether you can import your own gifs etc., yes, although you will have to experiment to see which graphic format works best for you. Some prefer pngs. : )

Re: Hi I'm new here. I have a question about camera..

PostPosted: Tue Jun 24, 2008 1:11 am
by DST
Interesting that Cat was the only one of us that noticed that question in his post.....