Problem shaking the screen with camera sprite

0 favourites
  • 8 posts
From the Asset Store
Is a circular loading screen with code ready to use. No Animation.
  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Might try your own using scroll.x, scroll.y, and a variable.

  • 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.

  • 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? :)

  • Well you can have many different variables.

    Like:

    +-global.value("shake") =1

    -every n seconds set scroll.x to scroll.x +(-5+random(5))

  • 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.

  • 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,

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)