Skip to content

Commit c5aefde

Browse files
committed
Merge pull request #578 from fodinabor/SpriteExampleFix
Updates the SceneSprite example
2 parents 5b2df60 + 2ac17ab commit c5aefde

File tree

8 files changed

+49
-14
lines changed

8 files changed

+49
-14
lines changed

Core/Contents/Include/PolySceneSprite.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ namespace Polycode {
119119

120120
class SpriteSet : public ResourcePool {
121121
public:
122-
SpriteSet(String imageFileName, ResourcePool *parentPool);
122+
SpriteSet(String imageFileName, ResourcePool *parentPool = CoreServices::getInstance()->getResourceManager()->getGlobalPool());
123123
~SpriteSet();
124124

125125
void setTexture(Texture *texture);

Examples/C++/Contents/SceneSprites/HelloPolycodeApp.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "HelloPolycodeApp.h"
22

33
HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) : EventHandler() {
4-
54
core = new POLYCODE_CORE(view, 640,480,false,true,0,0,90, 0, true);
65

76
CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
@@ -12,11 +11,12 @@ HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) : EventHandler() {
1211
Scene *scene = new Scene(Scene::SCENE_2D);
1312
scene->getActiveCamera()->setOrthoSize(640, 480);
1413

15-
SceneSprite *sprite = new SceneSprite("Resources/sprite_sheet.png", 93, 78);
16-
sprite->setScale(6,6);
17-
scene->addChild(sprite);
18-
sprite->addAnimation("ExampleAnimation", "0-29,29x6", 0.03);
19-
sprite->playAnimation("ExampleAnimation", 0, false);
14+
SpriteSet *sprite = new SpriteSet("Resources/sprite_set.sprites");
15+
SceneSprite *sceneSprite = new SceneSprite(sprite);
16+
sceneSprite->setSpriteByName("Explosion");
17+
sceneSprite->setSpriteStateByName("default", 0, false);
18+
sceneSprite->setScale(4, 4);
19+
scene->addEntity(sceneSprite);
2020
}
2121

2222
HelloPolycodeApp::~HelloPolycodeApp() {
1.95 KB
Loading
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" ?>
2+
<sprite_set>
3+
<sprite_sheet fileName="Resources/explosion.png">
4+
<frames>
5+
<frame id="0" x="0" y="0" w="0.0555556" h="1" ax="0" ay="0" />
6+
<frame id="1" x="0.0555556" y="0" w="0.0555556" h="1" ax="0" ay="0" />
7+
<frame id="2" x="0.111111" y="0" w="0.0555556" h="1" ax="0" ay="0" />
8+
<frame id="3" x="0.166667" y="0" w="0.0555556" h="1" ax="0" ay="0" />
9+
<frame id="4" x="0.222222" y="0" w="0.0555556" h="1" ax="0" ay="0" />
10+
<frame id="5" x="0.277778" y="0" w="0.0555556" h="1" ax="0" ay="0" />
11+
<frame id="6" x="0.333333" y="0" w="0.0555556" h="1" ax="0" ay="0" />
12+
<frame id="7" x="0.388889" y="0" w="0.0555556" h="1" ax="0" ay="0" />
13+
<frame id="8" x="0.444444" y="0" w="0.0555556" h="1" ax="0" ay="0" />
14+
<frame id="9" x="0.5" y="0" w="0.0555556" h="1" ax="0" ay="0" />
15+
<frame id="10" x="0.555556" y="0" w="0.0555556" h="1" ax="0" ay="0" />
16+
<frame id="11" x="0.611111" y="0" w="0.0555556" h="1" ax="0" ay="0" />
17+
<frame id="12" x="0.666667" y="0" w="0.0555556" h="1" ax="0" ay="0" />
18+
<frame id="13" x="0.722222" y="0" w="0.0555556" h="1" ax="0" ay="0" />
19+
<frame id="14" x="0.777778" y="0" w="0.0555556" h="1" ax="0" ay="0" />
20+
<frame id="15" x="0.833333" y="0" w="0.0555556" h="1" ax="0" ay="0" />
21+
<frame id="16" x="0.888889" y="0" w="0.0555556" h="1" ax="0" ay="0" />
22+
</frames>
23+
</sprite_sheet>
24+
<sprites>
25+
<sprite name="Explosion">
26+
<states>
27+
<state name="default" fps="20" scale="1" width="32" height="32" offset_x="0" offset_y="0" frame_ids="0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16" />
28+
</states>
29+
</sprite>
30+
</sprites>
31+
</sprite_set>

IDE/Contents/Source/PolycodeSpriteEditor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,8 @@ void SpriteStateEditBar::refreshBar() {
960960
meshGrips->clearMesh();
961961
meshGrips->indexedMesh = true;
962962

963-
Number frameOffset;
964-
Number frameSize;
963+
Number frameOffset = 0;
964+
Number frameSize = 0;
965965

966966
unsigned int offset = 0;
967967
unsigned int offsetIcon = 0;

Modules/Contents/UI/Include/PolyUIScrollContainer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ namespace Polycode {
104104
*/
105105
Number getVScrollWidth();
106106

107-
UIVScrollBar *getVScrollBar() { return vScrollBar; }
108-
UIHScrollBar *getHScrollBar() { return hScrollBar; }
109-
107+
UIVScrollBar *getVScrollBar();
108+
UIHScrollBar *getHScrollBar();
109+
110110
private:
111111

112112
Number defaultScrollSize;
@@ -119,8 +119,8 @@ namespace Polycode {
119119
bool hasHScroll;
120120
bool hasVScroll;
121121

122-
UIVScrollBar *vScrollBar;
123122
UIHScrollBar *hScrollBar;
123+
UIVScrollBar *vScrollBar;
124124
};
125125

126126
}

Modules/Contents/UI/Source/PolyUIScrollContainer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ Number UIScrollContainer::getVScrollWidth() {
115115
}
116116
}
117117

118+
UIVScrollBar *UIScrollContainer::getVScrollBar() { return vScrollBar; }
119+
120+
UIHScrollBar *UIScrollContainer::getHScrollBar() { return hScrollBar; }
121+
118122
void UIScrollContainer::setContentSize(Number newContentWidth, Number newContentHeight) {
119123

120124
if(newContentWidth < 1.0)

Modules/Contents/UI/Source/PolyUITextInput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2396,7 +2396,7 @@ void UITextInput::updateWordWrap(int lineStart, int lineEnd) {
23962396
void UITextInput::readjustBuffer(int lineStart, int lineEnd) {
23972397

23982398
if(scrollContainer) {
2399-
scrollContainer->getVScrollBar()->setTickSize((UI_TEXT_INPUT_SCROLL_SPEED * lineHeight) /scrollContainer->getContentSize().y);
2399+
scrollContainer->getVScrollBar()->setTickSize((UI_TEXT_INPUT_SCROLL_SPEED * lineHeight) / scrollContainer->getContentSize().y);
24002400
}
24012401

24022402
if(lineEnd == -1) {

0 commit comments

Comments
 (0)