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 / How to Use Animated Sprites on a 3D Plane Object (I have no exp with 3D Objects and AGK2)

Author
Message
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 5th Feb 2016 18:39
Hello,

I tried searching the forums for this, but I couldn't find anything. I remember someone asking a while ago, but I suppose my search phrases were just wrong.

Anyway I would like to use a 3D Plane Object with animated 2D sprites "projected"(?) onto it. The 3D documentation examples are waaaaaaaaaaaaaaaaaaaay out of date using re-purposed/refactored/non-existent methods, so I am stuck. As I said I have zero experience with 3D and AGK2.

Why do I want to do this? Currently I am implementing screen shake functionality by way of moving sprites around in random x and y directions then returning them to their original positions previous to being shaken. Ideally I would just like to utilize a camera for this rather than changing the position of every single active sprite... I have other ideas for how 3D could help me out in this and other projects. If there is even a way to get physics to work doing this, that would be really cool (not keeping my hopes up, though). Another option I've considered is using blender to make 3D objects of my sprites, but I'd like to avoid that process. Although, it could also open more possibilities for adding that extra pizzaz to my project.

Thanks ahead of time!
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 5th Feb 2016 23:58
Why not just using SetViewOffset() if all you want to do is move the camera in 2D?
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 6th Feb 2016 01:05
Quote: "Why not just using SetViewOffset() if all you want to do is move the camera in 2D?"

Wow, I over thought that a bit. Regardless is there a way to do what I asked?

Thanks, Digital Awakening.
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 6th Feb 2016 11:35
I've not touched the 3D myself so this is more like a good guess. The animation command is for sprites. But you can manually alter the image of a 3D object. If you want to use a tiled image for animation then make it into an atlas image.

You are welcome
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 6th Feb 2016 22:06
For now I'm setting the screen offset using SetViewOffset(Random2(-10,10), Random2(-10,10)). I do this for a certain number of cycles depending on the situation; which adds the effect I was looking for. Saved me a ton of time compared to what I was doing.
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 7th Feb 2016 08:55 Edited at: 7th Feb 2016 08:55


When you don't know the language it's goo to look through a lot of the commands in each section that is relevant to your project. There's a list of display commands in the core section that are really good to know about before you do anything serious.
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 7th Feb 2016 20:33
Quote: "When you don't know the language it's goo to look through a lot of the commands in each section that is relevant to your project. There's a list of display commands in the core section that are really good to know about before you do anything serious."

Yeah, it probably doesn't help that I only use "search" rather than the specific section relating to what I'm trying to do. I just never figured SetViewOffset was what I wanted to use since I have never used it in any of my prototypes. The stuff I've been doing doesn't do scrolling or anything like that.
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 7th Feb 2016 23:26
That's why it's good to look through all the commands. You can't really guess what the command is going to be called, and in most cases that one even exist. The display commands are super important to know if you ask me. Can save you a ton of work later. It covers virtual resolution, world and screen coordinates and many many more things. It's a must know if you want to support multiple resolutions, advanced layouts and scrolling levels. It's better to start coding with these in mind than having to work them in later.
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 8th Feb 2016 17:11
What do you mean by support multiple resolutions? I figured virtual resolution handled that for you, so it always looks the same in every environment. In the user guide they discuss coding by percentage, but again isn't that just virtual resolution the hard way?
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 8th Feb 2016 19:21
No, it's not that easy with screen of different aspect ratios. Unless you are fine with black borders. I think there's an easy work around for percentage system. I don't think Apple allows black borders. I recommend not using the percentage but a proper resolution. Percentage is simply 100x100 virtual resolution. It's perhaps easier to start with but you are likely to run into problems sooner or later. Depending on what you are making of course. I think it's better to learn how resolution works with images, text etc. It can be hard to wrap your head around it at first if you don't have experience with this before. Once you start on a project it's hard to switch so you need to decide on the method you want to use. A lot of users swear on the percentage way so do as you please
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 9th Feb 2016 19:32
Currently my app is using a virtual resolution of 1280×720 based on my Samsung Note 2. On smaller phones it looks fine, but I haven't been able to play it on anything bigger or with a higher resolution. Is it possible that if I move up to a high resolution device that it will have a black border?
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 10th Feb 2016 10:25
1280x720 is a 16:9 resolution and will look the same on all 16:9 resolutions. But there are plenty of 16:10 and 4:3 displays out there and those will get black borders. Not common on phones for sure. iPad is 4:3 and 16:10 is not that uncommon for PC. There are also other formats.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 10th Feb 2016 17:44
To avoid black borders I recommend looking at SetScissor(0,0,0,0) which will expand the viewable area beyond your chosen resolution where possible. You can also use the following commands to place GUI elements at the edges of the screen
GetScreenBoundsLeft()
GetScreenBoundsRight()
GetScreenBoundsTop()
GetScreenBoundsBottom()
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 10th Feb 2016 21:14
Well, this changes things a bit. I didn't consider differing aspect ratios; I understood the standard was 16:9. I'll need to go back, and play with Paul's suggestions keeping in mind the information that Digital Awakening provided.
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 10th Feb 2016 21:43
Yeah, I use SetScissor(0,0,0,0) for my game. The GetScreenBounds commands didn't exist at first so I've coded without them.

The solution to different aspect ratios depends on the type of game you are making. Sometimes it means filling out the space with additional art, sometimes it means that you show more of a level/map.

If you want to make a serious project. Learning these things first makes your life a lot easier later. And it's great experience, once you know it you can use it in all future projects.
Preben
AGK Studio Developer
19
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 12th Feb 2016 11:29
Another alternative is to calculate it yourself. i use something like this:

You define a maxwidth, say 1024 and it wil calculate the best possible width on the device its running on, and set the height to fit the device perfectly without any borders.



After this you can place your sprites etc... using the screenwidth and screenheight.

Also i sometimes use a scale factor when setting sprites gui stuff etc.. something like this:

global guiscale# = 0.75 // use it to increase decrease size.
SetSpriteScale(sprite,guiscale#,guiscale#)
SetSpritePosition(sprite,(guix+32.0)*guiscale#,(guiy+78.0)*guiscale#)

so you can increase the size of your sprites if they are display on a high resolution device.

So yes i agree this is what need to be done before you code anything else, everything will depend on the resolution of the device


best regards Preben Eriksen,
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 13th Feb 2016 22:13
What I do to deal with the different display ratios is to start with the SetScissor(0,0,0,0) command and then paste a background image that is large enough to cover a wide variety of resolutions and center it in the display. Then the areas that would be black are now showing the background image.

You can even make use of the black border space to deliberately display things.

In my poor WIP (not able to have time for it lately), I even use an animation that is bigger than my target resolution to show an active out of bounds area. If the device the app is playing on has the same height/width ratio as my target resolution, it isn't visible. But if it isn't, you see the 'hyperspace' animation above/below or left/right.

My target resolution is 960 wide by 640 high (landscape for old iphone). My background image is 1280x1024.
Cheers,
Ancient Lady
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 13th Feb 2016 23:03
Drawing a big sprite that fills the entire screen can however use up a lot of the graphics power on some phones. It's better to make a frame of 4 sprites surrounding your game view. This frame can be placed above ingame graphics if you have scrolling levels. Although in most cases I would recommend allowing scrolling levels to also fill the black bars. That's how I do it in my game.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Feb 2016 04:08
Since the background is part of the app, it's just one image that overflows to cover the black bands.

My app is not a scroller, so, what I do is actually just right for me. Only one image needs to be managed.
Cheers,
Ancient Lady
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 14th Feb 2016 08:39
Ah, I misunderstood. Sounded to me like you had one image behind the actual game
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Feb 2016 18:22
Cool, now I understood what you meant.
Cheers,
Ancient Lady

Login to post a reply

Server time is: 2024-04-19 21:33:14
Your offset time is: 2024-04-19 21:33:14