現在DxLibを用いてゲームのフレームワークを作っています。
C++
1#include "Actor.h" 2#include <memory> 3 4void Actor::draw() { 5 DrawGraph(position_.x, position_.y, renderer.GetTextureHandle(texture_), TRUE); 6} 7void Actor::react(std::shared_ptr<Actor> other) {} 8 9bool Actor::is_collide(std::shared_ptr<Actor> other)const { 10 DXrect my_rect{ position_.x, position_.y, position_.x + size_.x, position_.y + size_.y }; 11 DXrect other_rect{ other->position_.x, other->position_.y, 12 other->position_.x + other->size_.x, other->position_.y + other->size_.y }; 13 14 return CollisionRectAndRect(&my_rect, &other_rect) == DX_TRUE; 15} 16 17// 衝突処理 18void Actor::collide(std::shared_ptr<Actor> other) { 19 if (is_collide(other)) { 20 react(other); 21 22 23// ここが問題の場所=================================================================== 24 other->react(*this); 25// ================================================================================= 26 } 27}
Actorクラスというゲームに登場する全てのキャラクターが継承するベースクラスのcppファイルです。
ここのreactに自分自身のポインターを渡したいのですが、この方法ではエラーになってしまい困っています、、、。
何かいい方法はないでしょうか。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/08 08:06