Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Screen Shake

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 9th Jul 2016 12:07
Hi.

I want make shake camera in my 2d game. but I don't know how can do it.
is anyone to help me?

Thanks.
Thestroyer
8
Years of Service
User Offline
Joined: 14th May 2016
Location:
Posted: 9th Jul 2016 12:45
the command FixSpriteToScreen() can help. I dont know if you can move the sprite with setSpritePosition afterwards, but if it's not possible you have to turn FixSpriteToScreen() on for all sprites when you want the screen to shake and then move the screen with SetViewOffset() and then turn FixSpriteToScreen() off for all sprites.
If you can move the sprites when they are fixed to the screen you can just turn it on once for all the sprites and if you want the screen to shake you move the screen with SetViewOffset().
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 9th Jul 2016 14:46
I wrote a tutorial and drop-in module here.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 9th Jul 2016 19:19
Thanks Thestroyer.

Thanks BatVink for Your tutorial.
easter bunny
11
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 11th Jul 2016 04:14
Here are some functions I've been using for camera shake:




Just call Shake() every frame [ ie right before Sync()]. When you want to shake the screen just use 'shaking=1'.

Audacia Games - Latest WIP - AUTOMAYTE 2.1, AppGameKit one click deploy to Android
130,000 installs with AppGameKit and counting
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 11th Jul 2016 04:32
Thanks easter bunny for your help.

+1

Login to post a reply

Server time is: 2024-09-29 15:19:29
Your offset time is: 2024-09-29 15:19:29