Problem shaking the screen with camera sprite

Get help using Construct 2

Post » Fri Dec 30, 2011 5:25 am

Hi all,

Been hard at work and still loving C2,

One thing though ive just noticed is that I can set the screen to shake on demand when the "scroll to" behaviour is on my player sprite, but not when the behaviour is set to my camera sprite.

Has anyone else noticed this? Perhaps a bug? Or I am missing something simple... most likely the latter.

Anyhow, any help on this issue would be greatly appreciated!
ImageImage
B
74
S
17
G
6
Posts: 1,039
Reputation: 10,605

Post » Fri Dec 30, 2011 7:46 am

Might try your own using scroll.x, scroll.y, and a variable.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Fri Dec 30, 2011 8:21 am

Thanks for the suggestion Newt,

I have been mucking around this afternoon with different styles,

I initially had the scroll set to player.x+150, player.y (so my character wasnt in the middle of the screen), but found out through trial and error that the "shake" action only works when it is simply player.x, player.y. With the distance modifier it has no effect at all.

Is it supposed to function this way? I would have thought that you could shake the screen from any position.

Or did you mean for me to create my own screen shake effect through events?

...lol, one day i will be pro at this.
ImageImage
B
74
S
17
G
6
Posts: 1,039
Reputation: 10,605

Post » Fri Dec 30, 2011 8:56 am

Ok.

I figured out where i went wrong, for other newbies out there the "shake" option that you get access to through the "scroll to" behaviour doesnt work if you are trying to use it in conjunction with the system action "scroll to".

Hopefully using a different method to distance myself from the camera will allow the shake to work normally. Fingers crossed.


Update: Lol i really feel stupid now, the shake works fine now that im not using the system action to set the position of the camera. I now have a camera positioned perfectly with : Camera -> Set position player.x+250 player.y.

Can i have my Total Newb badge now Scirra? :)GenkiGenga2011-12-30 09:18:27
ImageImage
B
74
S
17
G
6
Posts: 1,039
Reputation: 10,605

Post » Fri Dec 30, 2011 3:43 pm

Well you can have many different variables.
Like:
+-global.value("shake") =1
>-every n seconds set scroll.x to scroll.x +(-5+random(5))
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Sat Dec 31, 2011 3:10 am

Ah Nice, more to play with :)

Thanks again Newt i'll try this out now, (the other style works but its a bit stiff on the camera while scrolling).

Happy New Year guys.
ImageImage
B
74
S
17
G
6
Posts: 1,039
Reputation: 10,605

Post » Thu Jan 26, 2012 10:41 pm

The shake behaviour in CC is quite good. I replicated the shaking using events only. Here is how you shake a sprite.

# ix and iy is the initial position of the object
+ System: Trigger once
-> Sprite: Set 'ix' to.x
-> Sprite: Set 'iy' to.y

# i=intensity, f.e:150
-> Sprite: Set position to lerp('ix',.x+ 'sx', 1-0.00009^TimeDelta), lerp('iy',.y+'sy', 1-0.00009^TimeDelta)
-> Sprite: Set 'sx' to random('i')
-> Sprite: Set 'sy' to random('i')

I'm not good at any Scirra product, but atleast I got it to work.
It creates a very smooth shake,
B
18
S
4
G
1
Posts: 413
Reputation: 2,512

Post » Sat Jan 28, 2012 7:48 am

Hi Urled,

That looks like some hectic coding but i'll give it a shot :) - I did end up getting it working smoothly but its always good to learn new ways.

Thanks for sharing that mate.
ImageImage
B
74
S
17
G
6
Posts: 1,039
Reputation: 10,605


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go and 20 guests