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.

Newcomers AppGameKit Corner / Display sprites - query

Author
Message
zxretrosoft
AGK Developer
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location: Prague, Czech Republic
Posted: 27th Jan 2016 07:01 Edited at: 27th Jan 2016 07:02
It is interesting that when you create a sprite that is automatically placed on the screen.
When I create 1000 sprites, then all will be on the screen. That's weird. I just want it to load into memory so that it could work with them in the future.
Whether to place the sprite on the screen should be controlled by the programmer. But here in the main loop is no PlaySprite() or something.

How can it do so, I had just sprites in memory, and I called them on the screen in the future? Thanks

I am sorry for poor English
JohnnyMeek
11
Years of Service
User Offline
Joined: 23rd Apr 2013
Location: Slovenia
Posted: 27th Jan 2016 07:42
Use SetSpriteVisible or use a function like this to initialise your sprites.
zxretrosoft
AGK Developer
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location: Prague, Czech Republic
Posted: 27th Jan 2016 08:03 Edited at: 27th Jan 2016 08:05
Thank you!
SetSpriteVisible() is one of the possibilities. But this means: On the screen are all sprites, but 90% of them will be hidden?...
It's very difficult for the processor. Better to show only the sprite that I use.
I am sorry for poor English
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 27th Jan 2016 08:58
The point of a sprite is to make a screen-based representation of an image. If you don't need it to be on screen, then you can do a number of things, in order of preference...

1. Don't create the sprite until you need it (may cause a small delay if you try to create a lot of sprites in one cycle)
2. Create the sprite as hidden, and at a coordinate offscreen (e.g -1000,-1000)
3. Create the sprite as hidden but still in the viewable area (You should only do this as a last resort)

AGK is a programming language, not a drag&drop style engine. So most of the logical decisions are made by you, not the engine. The engine does not know if you want a sprite to be hidden or displayed by default. In most scenarios if a sprite is created it is because it should be displayed, so it is logical that this is the default behaviour.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
zxretrosoft
AGK Developer
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location: Prague, Czech Republic
Posted: 27th Jan 2016 09:33
Well, thank you very much!
I am sorry for poor English

Login to post a reply

Server time is: 2024-11-21 21:15:38
Your offset time is: 2024-11-21 21:15:38