going from a scrollable position to a nonscrollable position?
Ran into a little problem today, i want to spawn an item into a scrollable layer and then have that item interpolate to a nonscrollable layer(the HUD). Im making an rpg and when the player collects a resource, I want to spawn the item from the node(scrollable layer) and interpolate its position to your inventory which is a nonscrollable layer. the problem is the grid coordinates (350,820) mean something different to the nonscrollable layer than to the scrollable layer..
Any help would be greatly appreciated!
Best Answer
-
kobayaashi Posts: 143
Would it not be possible to gauge the position of the resource relative to the current camera position, interpolate to the location the resource would appear on the hud, then spawn a version on the hud layer while destroying the original? Or am I way off base..?
Answers
Can't do it. For one even if both layers were the same you can't switch layers period. Matching a hud layer with a scrollable is impossible.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
@kobayaashi no you are definitely onto something! Im gonna play around with that idea, think it should work!
That's what I was thinking, too...
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
This is actually pretty simple. Have the actor on the scrollable layer change a game attribute (I used a boolean) and then have an actor on the non-scrollable layer spawn an actor relative to itself or relative to the scene when that attribute changes value.
The attached demo was made in Mac Creator. Click to spawn.
Edit: see the demo attached to the post below.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
It needs a few more things to do exactly what you described... I'll see if I can add them.
Edit: Hmm... having the scrollable actor spawned means that you can't access the camera controls. But I think I can work around that...
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
This is a little off, position-wise, but close!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
There's an offset of about 177 pixels horizontally (x) and 135 pixels vertically (y) between the click location and the spawn location. I'm not sure what that's about but I just manually adjusted the spawn location. So my best effort is this (demo attached):
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Fun!
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Lookin' good, @Armelline. I haven't checked out the file yet but how did you solve the offset issue I ran into?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Very seamless.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
I'm not sure. I just didn't encounter it What I suspect is the case is this:
The scrolling items are on a scene-wide X position. So if the camera has been moving a while, they might be at self.position.X 2500. The spawner, however, is on a screen-wide X position. So if the object is at self.position.X 2500, the spawner needs to spawn the object at 2500-camera.origin.X.
A non-scrollable layer always has 0 as the left of the screen and (in this case) 1024 as the right. No matter where the camera has moved to.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support