Why does my sceneview break when I put values over2048 ?
Hello, I finally created an account out of frustration, I’m building a game and I want my view's bounds to be bigger than 2048 but whenever I set it to anything more than 2048 everything in my scene disappear and I’m left with a black square. Is it some rendering limitation or am I missing something ?
@mwsx, in general, you should not need to create a view bigger than your screen, because you can pan your scene around indefinitely, as demonstrated by this example that pans to another ship, initially placed outside the visible area:
from scene import * class MyScene (Scene): def setup(self): self.background_color = 'midnightblue' self.ship = SpriteNode('spc:PlayerShip1Orange', parent=self) self.ship.position = self.size / 2 self.ship2 = SpriteNode('spc:PlayerShip1Green', parent=self) self.ship2.position = self.size * 2 self.run_action( Action.move_to(*( (0, 0)-(self.size * 1.5) ), 5) # seconds ) run(MyScene())
... but you might really need or want to, in which case it would be helpful to see some stripped-down version of your code that demonstrates the issue.
I do need my view to be bigger.
I just Need to know why are sceneview's bounds limited to 2048 and if it's fixable.
I really can’t find any info about this anywhere it's driving me crazy ^^
I could paste the code but I can’t really strip it I mean I can but it’s still gonna be big and messy and it wouldn’t answer why 2048 and not 2049 ;(
Since scenes use GPU for compositing, I believe they are limited based on GPU limitations. Note that (iirc) scene sizes are specified in points, not pixels -- so, if you have an iPhone 11 max, the size you want is 414x897 pts, even though in pixels this is 2600+.
I think you can create scene.Layers or scene.Nodes that are larger, and just move it around within the scene. But the scene never needs to be larger than your screen (I guess if you wanted a SceneView inside a scroll view... But just implement a scene based scroll view)
Ok thanks that kinda make sense I had to use every trick to make my scene move around and give the illusion of player moving freely in an infinite map I didn’t know there was such thing as scroll view I’ll check about that too.
Edit: yeah scroll view is actually what Ive been trying to create myself thinking there was no such thing implemented..so thanks this will make me gain a lot of time :))
@mwsx, sorry, but I have to ask: did you run and understand the panning example above?
Try creating a large Node, instead of a large Scene. Think of the Scene as a viewport, a window into a larger world.
The Node can be the parent of all other objects, and can move relative to the scene.
There may be issues with creating a huge background map full of spritenodes- but I'm not sure-- one could imagine logic which creates and disposes background tiles as they near the viewport.
@JonB, there is no need for an additional Node, as Scene is a Node that can be moved freely in the view (as demonstrated above).
Additional Nodes are useful for creating layers, to keep for example foreground clearly separate from a tiled background. Or several backgrounds that move at different speeds, for that classical parallax effect.
mwsx last edited by
@mikael Hey, yes I ran your code and I don’t understand how I can use it in my context, but I don’t understand anything anymore anyway so I’ll try to explain:
- I have a scroll view that has a background image with the same size, which is gonna be my map (which the player is be able to drag trough )
-I need the scene basically to instantiate and animate stars and particles etc.
- I want those stars to instantiate and animate to the entire area of the scrollView, not only to my scene bounds. I also need the scene background to be transparent so only the stars are visible and the background image of my scrollview not the bg of sceneview.
-then I have my player that is also part of my scene because it has animations.
-And a joystick that controls the player position relative to the scrollview area and not the sceneview but it has to keep its own position relative to the sceneview.
So I’m really confused af now because I tried every combination and nothing seems to work together because of the parent/child relations between them. I know I’m missing something super simple I’m just so frustrated I can’t see it..
So if you know how it’s done to have of all that working together in a simple way I’d greatly appreciate it. Like I want a basic map size of my choice where the player move freely relative to the background but still being at the Center of the screen as if there was a camera following him. I tried so much things that lead to nowhere that I’m in apathy mode now you guys are my last hope <3
So, I think what you want is something like this:
MapNode, child of your Scene
PlayerNode, child of MapNode
You will have touch handling which adjusts the MapNode.position when dragging on the map. If you want to be able to zoom the map/player using 2 finger pinch, then you should consider using @mikael 's pythonista-gestures... I forget if there is a specific version of this for scenes. Since your player is a child to MapNode, moving the map position moves the player with the map.
Your joystick moves the player position. Since the player is a child of the map, you don't need to worry about location within the scene, only the map.
Any other objects that you will have collision detection, etc would be child to the map. Any UI (fixed to the device screen) are child to the Scene.
You can use x_scale, y_scale, position and rotation on the map, to zoom the map, player and all.
mwsx last edited by
Ok I believe my problem came because I wanted to move the player where I should be moving the background like you said instead. I didn’t really grasp what a scene was until now. Thx to the both of you I think I’ll be ok now.
this is a very simple example, showing a large map consisting of tiles.
- map tiles
tapping near the edges moves the player one square.
dragging the map moves the map within the view.
tapping the buttons changes the mapnode scale.
Really large maps might be better handled with "chunks" that only get loaded when needed (when near the viewport) -- having 100000 Spritenodes uses a lot of memory.