castlevania like camera functions

Get help using Construct 2

Post » Fri Jun 21, 2013 1:36 pm

Hello all!

how do you get the camera function in Construct to act like the camera's that are used in Castlevania, i have searched in the forums for any answers around but the only ones i could find were 3 years old.

basically what i am after is a camera function that focuses the level to stay in the middle of the screen while having the camera lock onto the walls whenever the come into view instead of continuing to scroll past them and into nothingness.

any help would be appreciated!
B
5
S
1
Posts: 88
Reputation: 653

Post » Fri Jun 21, 2013 2:22 pm

Here's an example I made for another topic, but it should apply here as well. The method uses zones to define the camera's limits. The camera will follow the hero as long as it's within the hero's current zone.

Demo
Capx
B
61
S
18
G
8
Posts: 341
Reputation: 11,990

Post » Fri Jun 21, 2013 5:06 pm

oh very cool, ill give it a try! thanks!
B
5
S
1
Posts: 88
Reputation: 653

Post » Fri Jun 21, 2013 6:35 pm

i cant get it to work...

i have even copied the method to a T however now it has just jumped the camera to rediculous lengths chopping everything and anything.
ill fiddle with it some more on another day.
B
5
S
1
Posts: 88
Reputation: 653

Post » Sat Jun 22, 2013 1:39 pm

here goes my file any idea what the heck im doin wrong?
https://www.dropbox.com/s/pnayxlndx0rqg73/camera%20problems.capx
B
5
S
1
Posts: 88
Reputation: 653

Post » Mon Jun 24, 2013 7:06 am

BUMP!
B
5
S
1
Posts: 88
Reputation: 653

Post » Mon Jun 24, 2013 7:56 am

This should work:

Create an object called 'Camera'

Add the ScrollTo behaviour to it.

Add another two objects called Left_C and Right_C, put them where you want the camera to stop moving.

Add this to an event sheet and make sure the event sheet always runs while the player is moving around:

For every tick
     If Player.X > Left_C.X (and) Player.X < Right_C.X
           Camera.X = Player.X
     Else
           If Player.X >= Right_C.X
               Camera.X = Right_C.X
           If Player.X <= Left_C.X
               Camera.X = Left_C.X
ErekT2013-06-24 07:58:18
B
35
S
16
G
6
Posts: 525
Reputation: 7,483

Post » Mon Jun 24, 2013 10:39 am

hmm... i dont think i did it the way its meant to be...

do you think you can check it out and see what i did wrong compared to your example?

https://www.dropbox.com/s/pnayxlndx0rqg73/camera%20problems.capx

Thanks for the help btw!
B
5
S
1
Posts: 88
Reputation: 653

Post » Mon Jun 24, 2013 2:09 pm

I think I missed your attempt to use my method. I did a quick edit to your recent capx to show you how to use zones.

Capx

A few things to note:
  • The capx will seemingly only work for horizontal scrolling, but that's becasue you have the window size much larger than the playable area. My method works best when the zones height and width are equal or larger than the game's window size.
  • I had to change the some of the numbers in the scrolling event to correspond to your game's windows width and window height. I'm guessing this is where you may have run into trouble before. I changed the numbers to correspond to your game's window width and window height divided by 2. If you change your game's window size, you'll need to update these values. Alternatively, you could use the expressions "WindowWidth/2" and "WindowHeight/2" to set these, but as I recall, things can sometimes get buggy on certain full screen modes (thought that may have changed with some recent updates).
  • Although I didn't test it, I'm sure ErekT's method would work fine. Personally, I don't like creating camera objects, but that's just me. One benefit of using the zone method is automatic transitions between zones.
  • A more detailed explaination of what the event means can be found approximately 2/3 of the way down this post.


I hope this helps.
B
61
S
18
G
8
Posts: 341
Reputation: 11,990

Post » Mon Jun 24, 2013 4:03 pm

Ah! that explains it,

it works like a charm now even with different levels, another problem i had was the character also had the scroll to feature i didn't realize that the camera would automatically lock on even without the event sheet mentioning it... at least that's what i think anyways. regardless, it works!

I think now is a good time to read up the link.
That is absolutely brilliant, Thank you both for the help!
B
5
S
1
Posts: 88
Reputation: 653

Next

Return to How do I....?

Who is online

Users browsing this forum: Aquanex2 and 1 guest