Switching Sprites

Get help using Construct 2

Post » Mon Nov 14, 2011 5:09 am

I want to have different scenes for each room. In my example the "Go to Room" buttons works great.

The "Switch RM1" button is supped to take you back to Room 1 which is does, but it is also is supped to change the sprite to the "Room 1 Scene 2" sprite.

http://dl.dropbox.com/u/49284765/Room%20Switch.capx

Do I need an Every Tick command here? That command is always confusing to me.Guyon2011-11-14 05:10:42
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Mon Nov 14, 2011 6:17 am

Your capx fixed

You needed animation frame, global variable and a correct inclusion of sheets.

Every tick is a condition that will executes the actions setted and test the subevents each frame of the game.

What you needed was "On start of layout" to test only once and display the correct frame on beginning of the layout.

I took the liberty to implement it on Room2 as you may have seen
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Mon Nov 14, 2011 4:20 pm

Many thinks Kyatric I never thought to use the animation for anything besides, well animating. LOL
Great outside the box use for that.

Have a great day!
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Wed Nov 16, 2011 4:27 pm

The Scene switch is working great, but when I hit the switch scene button in Room 2 it will not Enable my Swtich Scene Back Button in Room 1.

http://dl.dropbox.com/u/49284765/Room%20Switch%202.capx

Any guidance apprenticed
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Wed Nov 16, 2011 5:52 pm

Fixed again

A few notes, when going from one layout to another, consider the objects that are not global to be destroyed, and the objects in the "new" layout to be created again.
As you made your "SwitchSceneBackButton" of layout1 with the property enabled = no by default, then each time you "launch" this layout, the button will be deactivated.
You need another check on a global variable to make sure what "state" it should be in (enabled/disabled).

Also, try to keep the code for objects from a layout in the corresponding eventsheet (just to keep track of what is where).
For now it is not a big deal since you have less than 10 objects and only 2 layouts, but imagine what it will be like when having 1000 objects and 200 layouts.
You'll just lose yourself in trying to figure out what is working with what/where.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Wed Nov 16, 2011 6:22 pm

Great incite and explanation Kyatric.

That said, my game is going to be an event driven adventure. Sort for like an interactive mystery that has the same buttons for actions in each room. I was goign to have a layout for each room but after your explanation maybe I should just have 1 layout with all my sprite-backgrounds in that layout and just switch. Your thoughts?


Guyon2011-11-16 18:27:32
B
28
S
8
G
8
Posts: 530
Reputation: 7,154


Return to How do I....?

Who is online

Users browsing this forum: ManuelPerez and 27 guests