Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Creating an 'object' with many sprites?

Author
Message
Zen Jones
6
Years of Service
User Offline
Joined: 1st Jul 2017
Location:
Posted: 5th Jul 2018 14:23
I am wanting to provide a specific visual in my app. I'm looking to place tabs on my screen somewhere, and when the user clicks on those tabs, it changes the app mode by sliding data on or off the main viewscreen. The biggest issue is that there will be close to 300 sprites that will be getting moved (slid) on or off the screen. Obviously I can drop that significantly, by just making most of them invisible where they sit, and just sliding the main image for displaying the data in a meaningful way on and off the screen, but then I got to thinking, what if there's a way to group sprites together to make an object (obviously each sprite is inherently an object). But say, this sprite is a member of object Zed, and that sprite is a member of object Zed, and they are positioned on Zed thusly, and when I move Zed, this and that follow, keeping their position relative to their assignment on Zed. Anything like that in AppGameKit? If it exists already, I'm clearly just not thinking about it in the right way to find it. Thank you to everyone for stopping in to ponder my query.
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 5th Jul 2018 15:09
300 Sprites isnt that many really even on mobile devices so it might just be as easy to continue with groups of sprites each controlled by the tab they are on.

You could consider making each tab a render image. Then your final screen has say 5 overlapping sprites (one for each tab)...each showing the render image. You only update the render image each time that tabs content changes. You then slide these tabs in and out of view. Essentially your only displaying 5 tabs or so and updating those when you need to. Id guess you want to do collision checks on what is on the tabs and show text etc....that makes this harder but still possible.

Using an object is possible too and you can create an object as many quads to show the various parts of your UI in each tab. Moving the object would then move these off the screen. You would have to manually create the object, set all the contents of memblocks and control every single UI bit inside it. This is a significant amount of work really and I would try avoid that but it is possible.

IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 5th Jul 2018 20:52
Why not use SetViewOffset( x, y ) instead of moving a whole bunch of sprites?
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Jul 2018 08:36
My recommendation would be to create a snapshot of the tab when you need to move it. Under normal operation it works exactly as you have it coded now. When you move the tab, you get an image, put it on screen and hide the original sprites.
If the tab looks the same throughout, take an image of it before you start to speed up the response when you slide it.

Another alternative is to slide everything off using tweens. You can apply the tween and then just let AppGameKit do the rest. The beauty of tweens is that you can add a minor offset (time, speed, opacity) and get a much nicer effect. I used this technique in the panel below. Each row background all of the individual text elements are fading in and resizing. This could also be a sliding effect.
You will see in the top left that the tween counter is at 122, and it runs perfectly smoothly.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Jul 2018 14:33
Just drop all of your SpriteId's into an array and use a function like this (300 is nothing really to worry about):
Using AppGameKit V2 Tier 1
Zen Jones
6
Years of Service
User Offline
Joined: 1st Jul 2017
Location:
Posted: 7th Jul 2018 18:47
That tween tab is a beautiful implementation BatVink. I'll definitely consider it moving forward! I also like the array suggestion baxslash!
Thank you everyone for your input. Always learning new things here.
puzzler2018
User Banned
Posted: 7th Jul 2018 19:05 Edited at: 7th Jul 2018 19:06
Wow BatVink - thats an awesome piece of coding to produce that
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Jul 2018 21:32
Quote: "That tween tab is a beautiful implementation BatVink"

Quote: "thats an awesome piece of coding to produce that"


I appreciate the compliments but it's not that difficult to code. Here's some info that may help others to solve a challenge or two...

The data is from a spreadsheet. I export to JSON (simple interface for user in Excel). AppGameKit monitors a folder for files and imports them when they arrive.
The graphics are held in a "theme" folder. Pick a theme, the folder is changed and the game gets a whole new look.
The colour of the bars are picked in Excel and are part of the JSON.

The appearance of the table, bars, and data are all driven by working through an array (as Baxslash suggests), positioning and applying tweens with a simple algorithm. Positioning and other appearance functions are much easier when you spend time writing an algorithm that automates everything. Once you've done a basic implementation, you can make it work differently by parameterising all of the settings.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Login to post a reply

Server time is: 2024-03-28 12:03:18
Your offset time is: 2024-03-28 12:03:18