Forum Archive

Adding Landscape to Cascade

techteej

So I wanted to add a landscape mode to the cascade example, but using the scene.should_rotate didn't work.

I added:

def should_rotate(self, LANDSCAPE): 
    columns = 20

But it unfortunately did not do anything. I tried searching for some help on this, as I was going to add it to more projects, but there isn't much out there.

Thank you.

ccc

What happens if you change the should_rotate() method to return True?

def should_rotate(self, orientation): 
    columns = 20
    return True
Sebastian

According to the docs, the function should return True if the scene should be rotated.

techteej

@ccc Tried this, still does not work.

@Sebastian I just want to allow support for landscape or portrait, depending on what the orientation the user started the program in.

ccc

Is the method getting called when you rotate the device?

def should_rotate(self, orientation): 
    print('{}.should_rotate({})'.format(self, orientation))
    columns = 20
    return True
omz

I just want to allow support for landscape or portrait, depending on what the orientation the user started the program in.

In that case, just remove the orientation parameter from the run call at the end of the script, i.e. change it to run(Game()).

Then, you can simply add the orientation logic (change number of columns etc.) in the setup method (if self.size.w > self.size.h, you're in landscape mode).

techteej

@omz Thank you so much for responding. Truly great to get the app's developer to respond (not that I don't appreciate every one else's responses). If you could check out my other question, Help building a touch menu and help me figure that out it would be greatly appreciated.

[deleted]

This might sound stupid, but can't you just change portrait to landscape at the end of the code, then add a few columns and rows where the script is determining if your device is an iPad or iPhone? Or was that not the question at all?

techteej

@Qwerty2.17 that wasn't working, I had tried that.