Mintoris

Author Topic: Scrolling GUI using graphic  (Read 1617 times)

hoyoyo80

  • Full Member
  • ***
  • Posts: 66
Scrolling GUI using graphic
« on: Aug 04, 2016, 06:47 PM »
Hello,

Im drafting my app using graphics command,im thinking on having a scrolling GUI for my apps...how do i achieve this?

Thanks

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Scrolling GUI using graphic
« Reply #1 on: Aug 05, 2016, 08:27 AM »
Sorry Hoyoyo, the scope of that question is too big. I don't know where to start and my time is short today.

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Scrolling GUI using graphic
« Reply #2 on: Aug 05, 2016, 07:11 PM »
I would suggest you start becoming familiar with the game engine. Get some button sprites on the screen. Then, hook the sprites to an event sub that is triggered when the sprite is touched.

SetOnGenSpriteTouchSub

By the time you get that far I think you will be able to scroll the sprites around as you like. Keep us posted here and I will steer you in the right direction. The Game Engine mode has the potential to make incredible user interfaces. Unfortunately, the Game Engine's abilities extend far beyond what I've been able to explain so far. 

hoyoyo80

  • Full Member
  • ***
  • Posts: 66
Re: Scrolling GUI using graphic
« Reply #3 on: Aug 07, 2016, 08:29 PM »
Yes thanks. I know it quite general when talking about GUI. What i want to know just the idea behind scrolling in 2d. Like 3d, i can use camera to look at part of the scrolling menu.

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Scrolling GUI using graphic
« Reply #4 on: Aug 08, 2016, 04:22 PM »
Well, first of all, is this a Game Engine program?

hoyoyo80

  • Full Member
  • ***
  • Posts: 66
Re: Scrolling GUI using graphic
« Reply #5 on: Aug 08, 2016, 04:32 PM »
Actually im afraid game engine is too advance for me thats why i started in graphic mode but ill switch to GE

The idea of my next app is very similar with creating tilemap editor but lot simpler.

Additional: All my staff tablet is dual core asus. Can the device use gameengine mode?

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Scrolling GUI using graphic
« Reply #6 on: Aug 08, 2016, 04:37 PM »
Well whether you use the Graphics mode or the Game Engine mode, you will need two global scrollX and scrollY variables. When you go to draw each part of your menu add scrollX and scrollY to the graphic element's x and y position. Then, add or subtract any amount to scrollX & scrollY and all the graphics will scroll.

There is an automatic feature in the Game Engine that does this, but I haven't hooked it up yet. 

hoyoyo80

  • Full Member
  • ***
  • Posts: 66
Re: Scrolling GUI using graphic
« Reply #7 on: Aug 09, 2016, 03:13 AM »
Ok i get the idea behind that ;D i thought i can parent all the gui sprite to an background sprite for scrolling but now i get it.

When u said about touch sprite command, after touch down check, do i need to compare touch coord with sprite coord again? Or it will select the sprite automatically.

Thanks

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Scrolling GUI using graphic
« Reply #8 on: Aug 09, 2016, 11:57 AM »
The onSpriteTouch() sub automatically passes you the sprite that was touched as a parameter. If you need to identify sprites use the GenSetSpriteType command to give each sprite an ID.  You make up the sprite type values, then use the GenGetSpriteType(sprite) function to Identify a sprite.

Each sprite can also have it's own onSpriteTouch() sub that does different things for different sprites. The name of the sub onSpriteTouch() can be any name really just so it matches the name in the SetOnGenSpriteTouchSub.

In later updates I plan to make this type of scrolling much easier.