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 / [To Paul] Is this possible to make something like SetParentSprite or CreateCanvas (CreateSpriteCanvas) command?

Author
Message
Alex_Peres
AGK Master
14
Years of Service
User Offline
Joined: 13th May 2009
Location: The Milky Way Galaxy
Posted: 18th Oct 2016 15:19
Sometimes I neen something like canvas or changing layers to manipulate group of sprites as one. To use it for advenced GUI system.
Instead of this it can be kind of SetParentSprite(spriteNum, parentSpriteNum) command to fix one sprite to another, as it made in Unity or the other game-engines...
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 18th Oct 2016 15:59
It's easy enough to make your own sprite grouping commands.


Here is my text file , it uses a grouping system that you could replicate with sprites
AGK V2 user - Tier 1 (mostly)
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 18th Oct 2016 16:33 Edited at: 18th Oct 2016 16:36
a canvas id would be fine to switch between guis. but its similar to my request to have a own reference id field in the sprite struct.


Quote: "To use it for advenced GUI system. "

maybe just using DrawSprite with your own List of Sprites (Images) and a List Item using a User Defined Type with 2 IDs.
as example if you will move a window you need a function to get a list from a beginning id, and then u need function with parameter list and in a for next loop you change each position.

function SetSpritePositionXL(List[] as MyType, fX, fY )
for i=1 to List.count
iSpriteIndex=List[i]
SetSpritePosition ( iSpriteIndex, fX, fY )
next
endfunction

function SetUIPosition(List[] as MyType, fX, fY )
for i=1 to List.count
List[i].fX=fX
List[i].fY =fY
next
endfunction
AGK (Steam) V2.0.21 : Windows 10 Pro 64 Bit : AMD (16.6) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Alex_Peres
AGK Master
14
Years of Service
User Offline
Joined: 13th May 2009
Location: The Milky Way Galaxy
Posted: 18th Oct 2016 16:58
I'm talking about the easiest way for people. I want to have all that stuffs inside the game-engine. AppGameKit must be very simple and powerful.
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 19th Oct 2016 06:30
I've wanted something like this for a long time as well. It is very easy in other engines to create 'layers' or 'nodes' and attach children to them to manipulate as one. When I needed this functionality in AppGameKit I recall ending up using some mathematical equations and complex routines. Built-in grouping for sprite movement and manipulation would be nice.
JohnnyMeek
10
Years of Service
User Offline
Joined: 23rd Apr 2013
Location: Slovenia
Posted: 19th Oct 2016 07:31 Edited at: 19th Oct 2016 07:32
You can build this yourself. It just takes a lot of work.

I've built a fully parented system and GUI editor, maybe I should consider selling it on the TGCstore if there's enough interest.

Polaraul
9
Years of Service
User Offline
Joined: 13th Dec 2014
Location:
Posted: 19th Oct 2016 11:23
Alex_Peres wrote: "I'm talking about the easiest way for people. I want to have all that stuffs inside the game-engine. AppGameKit must be very simple and powerful."


This is one reason I always consider other engines before starting any new project in AppGameKit now. What takes lines of code to achieve in AppGameKit can very often be accomplished in just a line or two in other engines!
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 19th Oct 2016 12:01
Quote: "What takes lines of code to achieve in AppGameKit can very often be accomplished in just a line or two in other engines! "

If you want to use an engine then go ahead but if you want to use a programming language like AppGameKit then expect to write lines of code.
AGK V2 user - Tier 1 (mostly)
Alex_Peres
AGK Master
14
Years of Service
User Offline
Joined: 13th May 2009
Location: The Milky Way Galaxy
Posted: 19th Oct 2016 16:29
Scraggle,

AGK was conceived as a very simple game engine and it is. But it lacks some very simple and important functionality which every engine must have!

I think Paul already have all code he needs to make simple SetParentSprite command. I'm talking about the Skeleton2D system.
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 19th Oct 2016 16:35
Quote: "I'm talking about the easiest way for people. I want to have all that stuffs inside the game-engine. AppGameKit must be very simple and powerful."


that means that all sprite commands need a rewrite that it handle it sub sprites via optional recursive true/false argument.
i think that will be alot of work for paul.
but yes we all devs will have the benefit of this feature.
AGK (Steam) V2.0.21 : Windows 10 Pro 64 Bit : AMD (16.6) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Alex_Peres
AGK Master
14
Years of Service
User Offline
Joined: 13th May 2009
Location: The Milky Way Galaxy
Posted: 19th Oct 2016 17:15 Edited at: 19th Oct 2016 17:23
Quote: "i think that will be alot of work for paul."

I don't think so. Paul is pretty smart...
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 19th Oct 2016 18:10
you said it is also for a gui system, until paul made something for you this 2 commands maybe help
SetSpriteGroup ( iSpriteIndex, group )
GetSpriteGroup ( iSpriteIndex )
AGK (Steam) V2.0.21 : Windows 10 Pro 64 Bit : AMD (16.6) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Alex_Peres
AGK Master
14
Years of Service
User Offline
Joined: 13th May 2009
Location: The Milky Way Galaxy
Posted: 19th Oct 2016 20:13
thanks Markus, but I'm only talking about moving, scaling and rotating sprite which will depend on parent sprite...
Alex_Peres
AGK Master
14
Years of Service
User Offline
Joined: 13th May 2009
Location: The Milky Way Galaxy
Posted: 19th Oct 2016 20:58
Quote: "You can build this yourself. It just takes a lot of work.

I've built a fully parented system and GUI editor, maybe I should consider selling it on the TGCstore if there's enough interest. "


This is absolutely not what I want.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 19th Oct 2016 22:32
I think alex is talking about the movieclip concept in flash.
You can put anything in a movie clip, graphics, text even other movieclips
You can scale, move and rotate a movieclip just like you can with an image

i remember asking about it and i think BatVink suggested using physics objects and joints to join them together but i could never get it working
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 20th Oct 2016 08:08
Quote: "AGK was conceived as a very simple game engine and it is."

No it isn't. It's a programming language. A game engine is a very different animal.

AGK V2 user - Tier 1 (mostly)
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 20th Oct 2016 08:41
AGK2 (in my opinion) is a programming language with the addition of game-specific commands.
Game Guru is a game engine, with embedded actions that you trigger with game events.

In Game Guru, a character is automatically animated when he walks, and walking is a feature you don't have to think about, it just happens. These are features of a game engine.
In AppGameKit, you must write the code to make an object (character) move, and animate it while it is moving (walking). These are requirements of a programming language.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 20th Oct 2016 09:21 Edited at: 20th Oct 2016 09:22
however, a "programming language" have his librarys to make the developing simpler / rapid.
just "moving, scaling and rotating sprite which" is inconsequent in my opinion, so my suggestion is that we need sprite commands with a list input
and a command to get the hierarchy list. and i saw we need a SetSpritePositionMove Command for relative position.

example constructor
SetSpriteColor( iSpriteIndex, iRed, iGreen, iBlue, iAlpha )
SetSpriteColor( iSpriteIndexList[], iRed, iGreen, iBlue, iAlpha )

the list command call the single command
SetSpriteColor(iSpriteIndexList[], iRed, iGreen, iBlue, iAlpha )
for i = 1 to iSpriteIndexList.Count
iSpriteIndex=iSpriteIndexList[i]
SetSpriteColor( iSpriteIndex, iRed, iGreen, iBlue, iAlpha )
next
AGK (Steam) V2.0.21 : Windows 10 Pro 64 Bit : AMD (16.6) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 20th Oct 2016 09:43
I'm going to bring peoples attention back to my first post which contained the code to do everything that people are asking for. It seems nobody has looked at it.
That code deals with text objects but the conversion to sprite is simple.
I might work on a sprite version over the weekend.
AGK V2 user - Tier 1 (mostly)
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 20th Oct 2016 11:01 Edited at: 20th Oct 2016 15:28
I had a spare hour at work - here you go


Either copy/paste that into your code or save it and #include it (better option)
Use mygroup = CreateSpriteGroup()
then add sprites to the group with:
SetSpriteToGroup( sprite, mygroup)
Then perform things on your group of sprites such as SetSpriteGroupVisible(mygroup, state)

A sprite can be a member of multiple groups
You can remove a sprite from a group with RemoveSpriteFromGroup(spriteID, groupID)

[Edit] I've attached the AGC file
AGK V2 user - Tier 1 (mostly)

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 20th Oct 2016 21:26
That looks cool scraggle. One thing i noticed (just scanning) is that when you scale/position/rotate you simply iterate through the members and apply the property.

In a group, all objects are positioned relative to the center of the group.
When i rotate the group they all rotate around that point
When i scale they all scale relative to the groups center.

Like this;


I don't think it would be too much trouble to add this functionality. Also you can place groups within groups (recursive)
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 20th Oct 2016 23:46
That would be simple enough to put in. If I get a quiet day at work again tomorrow I will add it in. Along with Markus' latest request in the 'Feature Request' post. That could easily be applied to groups too.
AGK V2 user - Tier 1 (mostly)
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 21st Oct 2016 00:45
One other thing if i may (And i wouldn't bother with this one if it interferes with your model too much)
When i move or rotate and object within a group it is re-scaled according to it's scale AND the scale of the group.
Like this;


This allows you to create dependent scaling/rotation for a number of objects like so;
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 21st Oct 2016 07:25
Quote: "In a group, all objects are positioned relative to the center of the group.
When i rotate the group they all rotate around that point
When i scale they all scale relative to the groups center."


i think the key to it will be - save the offset, set a new offset to a central place, rotate/scale and set the original offset again.
GetSpriteOffsetX ( iSpriteIndex )
GetSpriteOffsetY ( iSpriteIndex )
SetSpriteOffset ( iSpriteIndex, x, y )
AGK (Steam) V2.0.21 : Windows 10 Pro 64 Bit : AMD (16.6) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Login to post a reply

Server time is: 2024-03-28 19:58:32
Your offset time is: 2024-03-28 19:58:32