bool HSBalloonSprite::ContainsTouchLocation( CCTouch* touch ) { if(!touch || !m_isTouchEnabled) { return false; } //return TextureRect().containsPoint(touch->getLocation()); return TextureRect().containsPoint(convertTouchToNodeSpaceAR(touch)); }
// Made an empty texture and bind it to $ptr_p // returns false if creating texture was unsuccessful // fbh and fdb should be properly shifted before calling this! // We should ignore framebuffer trouble here, as we put textures of different sizes to it. inline bool CRenderTarget::InitialiseDefaultTexture(u32 *ptr_p, int fbw, int fbh) { glGenTextures(1, ptr_p); glBindTexture(GL_TEXTURE_RECTANGLE_NV, *ptr_p); // initialize to default TextureRect(GL_RGBA, fbw, fbh, GL_RGBA, GL_UNSIGNED_BYTE, NULL); setRectWrap(GL_CLAMP); setRectFilters(GL_LINEAR); GLenum Error = glGetError(); return ((Error == GL_NO_ERROR) || (Error == GL_INVALID_FRAMEBUFFER_OPERATION_EXT)); }
void DemoState::HandleInput() { SDL_Event event; while (SDL_PollEvent(&event) != 0) { switch (event.type) { case SDL_QUIT: { quit_ = true; break; } case SDL_MOUSEBUTTONDOWN: { Vector2f mouse_location(Vector2i(event.button.x, event.button.y)); if (event.button.button == SDL_BUTTON_LEFT) { new_channel_location_ = mouse_location; } else { new_listener_location_ = mouse_location; } break; } case SDL_MOUSEBUTTONUP: { Vector2f mouse_location(Vector2i(event.button.x, event.button.y)); SDL_Texture* texture; texture = channel_texture_; auto channel_iter = std::find_if( channel_icons_.begin(), channel_icons_.end(), [mouse_location, texture](const ChannelIcon& icon) -> bool { SDL_Rect rect; TextureRect(&rect, icon.location, texture); return RectContains(rect, mouse_location); }); if (channel_iter != channel_icons_.end()) { channel_iter->channel.Stop(); channel_icons_.erase(channel_iter); break; } texture = listener_texture_; auto listener_iter = std::find_if( listener_icons_.begin(), listener_icons_.end(), [mouse_location, texture](const ListenerIcon& icon) -> bool { SDL_Rect rect; TextureRect(&rect, icon.location, texture); return RectContains(rect, mouse_location); }); if (listener_iter != listener_icons_.end()) { audio_engine_.RemoveListener(&listener_iter->listener); listener_icons_.erase(listener_iter); break; } if (event.button.button == SDL_BUTTON_LEFT) { pindrop::Channel channel = audio_engine_.PlaySound(sound_handle_); if (channel.Valid()) { channel_icons_.push_back(ChannelIcon()); ChannelIcon& icon = channel_icons_.back(); icon.location = new_channel_location_; icon.velocity = mouse_location - new_channel_location_; icon.channel = channel; } break; } if (event.button.button == SDL_BUTTON_RIGHT) { pindrop::Listener listener = audio_engine_.AddListener(); if (listener.Valid()) { listener_icons_.push_back(ListenerIcon()); ListenerIcon& icon = listener_icons_.back(); icon.location = new_listener_location_; icon.velocity = mouse_location - new_listener_location_; icon.listener = listener; } break; } break; } default: ; // Do nothing. } } }
void DemoState::DrawIcon(const IconState& icon_state, SDL_Texture* texture) { SDL_Rect rect = {0, 0, 0, 0}; TextureRect(&rect, icon_state.location, texture); SDL_RenderCopy(renderer_, texture, nullptr, &rect); }