Spawning Actors from Non-Scrollable to Scrollable
Conifer_Apps
Member Posts: 100
Ok guys, I've seen a lot of questions about this topic and I think it's time I created an official discussion on the topic of spawning from non-scrollable layers to scrollable layers. First and foremost, I'll share my solution. If you have and HUD item that when you tap it an actor spawns, the actor spawns in the non-scrollable layer. This can be a problem and as of yet the talented Gamesalad team hasn't released an build with this option. I came up with a solution that works in some cases.
My solution relies on attributes. First create two global real attributes, I'll call them Spawn_X and Spawn_Y. Then constrain the Spawn_X attribute to the X position of the HUD item, relative to the scene. Do this for the Spawn_Y attribute as well. Next create a boolean called Spawn_Actor. When the HUD item is pressed, change the Spawn_Actor boolean to true, otherwise constrain it to false. Then, with an actor on the scrollable layer, when Spawn_Actor is true spawn the actor you want to be spawned at position Spawn_X for the X value and Spawn_Y for the Y value. Having the actual spawner on the scrollable layer will ensure that the spawnee (I think that's the term) is spawned on a scrollable layer as well. The actor SHOULD spawn in the position of the HUD item that the user thinks spawned the actor.
As a full disclaimer, and honestly I don't have a clue as to why, this solution only sometimes works. Like I said, I don't have the slightest idea why. I'm guessing it has something to do with the coordinate constraining. Anyways, experiment with it and get back to me. If you have any better solutions I would love it if you shared them (see above; mine only sometimes works ). :-j
I guess the moral to this story is we need an update for Gamesalad Creator. That's really the only thing. Love the program otherwise. Who knows, I'm not pro, so someone tell me if this was fixed in a nightly build. Again, post your solutions and/or thoughts on mine. Thanks! Oh and possibly download my game.
________________________________________________________________________
Download Rescue the Monsters:
https://itunes.apple.com/us/app/rescue-the-monsters/id765075361?mt=8&uo=4
My solution relies on attributes. First create two global real attributes, I'll call them Spawn_X and Spawn_Y. Then constrain the Spawn_X attribute to the X position of the HUD item, relative to the scene. Do this for the Spawn_Y attribute as well. Next create a boolean called Spawn_Actor. When the HUD item is pressed, change the Spawn_Actor boolean to true, otherwise constrain it to false. Then, with an actor on the scrollable layer, when Spawn_Actor is true spawn the actor you want to be spawned at position Spawn_X for the X value and Spawn_Y for the Y value. Having the actual spawner on the scrollable layer will ensure that the spawnee (I think that's the term) is spawned on a scrollable layer as well. The actor SHOULD spawn in the position of the HUD item that the user thinks spawned the actor.
As a full disclaimer, and honestly I don't have a clue as to why, this solution only sometimes works. Like I said, I don't have the slightest idea why. I'm guessing it has something to do with the coordinate constraining. Anyways, experiment with it and get back to me. If you have any better solutions I would love it if you shared them (see above; mine only sometimes works ). :-j
I guess the moral to this story is we need an update for Gamesalad Creator. That's really the only thing. Love the program otherwise. Who knows, I'm not pro, so someone tell me if this was fixed in a nightly build. Again, post your solutions and/or thoughts on mine. Thanks! Oh and possibly download my game.
________________________________________________________________________
Download Rescue the Monsters:
https://itunes.apple.com/us/app/rescue-the-monsters/id765075361?mt=8&uo=4
Comments
The way to do this -- and I think you've described it though I'm a bit unclear from what you wrote -- is to have an actor on a different (scrollable) layer and trigger that actor to spawn another actor when some attribute (e.g. boolean) changes value.
If you're moving the camera, then you'd have to offset the location of the spawned actor by however far you've moved the camera from its initial origin.
Why this would only work sometimes for you, I can't guess. It should work every time.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User