Skip to content

Commit

Permalink
make the button nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool committed Sep 6, 2021
1 parent f065319 commit 53d5801
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/nodes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class NodeFactory {
_gen_func(setContentSize)
_gen_func(setOpacity)
_gen_func(setZOrder)
_gen_func(setAnchorPoint)

#undef _gen_func
};
22 changes: 21 additions & 1 deletion src/overlay_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <nfd.h>
#include <sstream>
#include "recorder_layer.hpp"
#include "nodes.hpp"

bool OverlayLayer::init() {
if (!initWithColor({ 0, 0, 0, 105 })) return false;
Expand Down Expand Up @@ -123,9 +124,28 @@ bool OverlayLayer::init() {
addChild(label);

btn = gd::CCMenuItemSpriteExtra::create(CCSprite::create("GJ_button_01.png"), this, menu_selector(OverlayLayer::on_recorder));
btn->setPosition({win_size.width - 35, -275});
{
auto draw_node = CCDrawNode::create();
constexpr size_t n_verts = 16;
constexpr float radius = 13.f;
CCPoint verts[n_verts];
for (size_t i = 0; i < n_verts; ++i) {
verts[i] = CCPoint::forAngle(static_cast<float>(i) / n_verts * 6.2831f) * radius;
}
draw_node->drawPolygon(verts, n_verts, {1.f, 0.f, 0.f, 1.f}, 1.f, {0.f, 0.f, 0.f, 1.f});
btn->getNormalImage()->addChild(draw_node);
draw_node->setPosition(btn->getNormalImage()->getContentSize() / 2.f);
}
btn->getNormalImage()->setScale(0.775f);
btn->setPosition({win_size.width - 35, -260});
menu->addChild(btn);

addChild(NodeFactory<CCLabelBMFont>::start("Internal Recorder", "bigFont.fnt")
.setAnchorPoint(ccp(1, 0.5))
.setScale(0.6f)
.setPosition(win_size - ccp(55, 260))
);

sprite = CCSprite::create("square02b_001.png");
sprite->setColor({0, 0, 0});
sprite->setOpacity(69);
Expand Down

0 comments on commit 53d5801

Please sign in to comment.